Here is your score for Assignment 6.
Score: TBD
Let me know if you have any questions regarding your score. And let me know if you want a copy of an example implementation for the assignment.
Regards,
Jade
Grading Guidelines
Test Results for Assignment 6
The following files were used during the tests:
-
ExampleInputFile.txt
Jade Cheng
foo
Hello world
bar
-
GoodInputFile-1.txt
ICS 211 Homework 6
Collection and Iterator assignment
In this assignment, you implement a class with an iterator. Your class must
provide the add, iterator, and size methods defined in the Collection interface,
but need not support any other methods defined for Collections.
The object returned by your iterator method must be of a class that implements
the Iterator interface (you define this class as well as your collection class).
The remove method must be present but should simply throw the appropriate
exception, so your iterator only really needs to support the next and hasNext
methods.
You may implement your collection class using either an array or a linked list
(at your choice) to store the objects in the collection. Be sure your collection
class is generic, that is, parametrized on a type T. If your collection class
has a fixed maximum number of objects it can hold, make sure that number is at
least 1,000.
As part of your collection class, you should implement a main method to test the
collection class itself. This main method must create a new collection class
object parametrized with the type String, then read one line at a time from a
file (specified on the command line), and insert each line into the collection.
Once the lines in the file have been added to the collection, the main method
must print the size of the collection, that is, the number of elements stored
in the collection.
The main method then uses the iterator to read back all the lines stored in the
collection, and print each line preceded by the number of characters in that
line.
It is OK if the iterator for the collection returns the lines in an order
different from the sequence in which the lines were added to the collection.
For example, if the file contains the following three lines:
Hello world
foo
bar
It would be OK for your program to print the lines as follows (the size is
printed first):
The collection has 3 items
3: foo
11: Hello world
3: bar
Turning in the Assignment
Email your assignment to the TA following the instructions here.
# javac -Xlint:all *.java
--> EXIT CODE: 0 <--
# java ChengJade6 ExampleInputFile.txt
The size of the collection is: 3
3: bar
11: Hello world
3: foo
--> EXIT CODE: 0 <--
# java ChengJade6 GoodInputFile-1.txt
The size of the collection is: 51
64: Email your assignment to the TA following the instructions here.
0:
25: Turning in the Assignment
6: 3: bar
15: 11: Hello world
6: 3: foo
26: The collection has 3 items
0:
15: printed first):
74: It would be OK for your program to print the lines as follows (the size is
3: bar
3: foo
11: Hello world
0:
60: For example, if the file contains the following three lines:
0:
76: different from the sequence in which the lines were added to the collection.
73: It is OK if the iterator for the collection returns the lines in an order
0:
5: line.
76: collection, and print each line preceded by the number of characters in that
79: The main method then uses the iterator to read back all the lines stored in the
0:
18: in the collection.
77: must print the size of the collection, that is, the number of elements stored
77: Once the lines in the file have been added to the collection, the main method
0:
79: file (specified on the command line), and insert each line into the collection.
77: object parametrized with the type String, then read one line at a time from a
76: collection class itself. This main method must create a new collection class
80: As part of your collection class, you should implement a main method to test the
0:
12: least 1,000.
78: has a fixed maximum number of objects it can hold, make sure that number is at
77: class is generic, that is, parametrized on a type T. If your collection class
80: (at your choice) to store the objects in the collection. Be sure your collection
78: You may implement your collection class using either an array or a linked list
0:
8: methods.
77: exception, so your iterator only really needs to support the next and hasNext
73: The remove method must be present but should simply throw the appropriate
80: the Iterator interface (you define this class as well as your collection class).
78: The object returned by your iterator method must be of a class that implements
0:
63: but need not support any other methods defined for Collections.
80: provide the add, iterator, and size methods defined in the Collection interface,
75: In this assignment, you implement a class with an iterator. Your class must
0:
34: Collection and Iterator assignment
0:
18: ICS 211 Homework 6
--> EXIT CODE: 0 <--
# java ChengJade6 GoodInputFile-2.txt
The size of the collection is: 0
--> EXIT CODE: 0 <--
# java ChengJade6 No-Such-File.txt
Unable to open the file.
--> EXIT CODE: 1 <--
# java ChengJade6
Usage: ChengJade6 path
--> EXIT CODE: 1 <--
# java ChengJade6 Argument-1.txt Argument-2.txt
Usage: ChengJade6 path
--> EXIT CODE: 1 <--