Professional Documents
Culture Documents
Collections
Date Assigned: Wed Sep 29, 2010
You will use ObjectEditor to display the elements of the collections. Thus, you
must follow ObejctEditor conventions for read methods of a variable-sized
collection. You do not need to do so for write methods. Moreover, while you
should use ObjectEditor to invoke methods to remove elements, you should
not use ObjectEditor to add elements to the collection. The reason is that
each of these collections consists of composite objects such as a shape and
ObjectEditor does not provide a convenient way to instantiate method
parameters that are composite objects. You can programmatically add
elements to connections in main and other methods of your class. Make
sure a collection is fully populated before you ask ObjectEditor to display it so
that you dont have to interactively add elements to it.
Besides collections, you will create other kinds of objects, which will
ultimately be associated with collections
Candy
Create a graphics class representing a candy. It can be a simple oval, as
shown below, or an image or a complex graphics object that is more realistic.
Candy Container
Create a graphics class representing a candy container an object, such as
the one shown below, that can contain multiple candies. You can assume a
limit on the number of candies that can be put in a candy container.
Candy List
Create a similar class that represents a collection of candies. This collection
should also support two write methods: a single-parameter method that adds
a candy (specified by the argument of the method), and a parameterless
method that removes the last added candy from the collection. Like the
house list, the collection does not determine the geometry of the elements
(positions and sizes) each element of the collection does.
House List
Create a class that represents a collection of houses (with mailboxes and
paths). The collection should support two write methods: a single-parameter
method that adds a house (specified by the argument of the method), and a
parameterless method that removes the last added house from the
collection. The collection does not determine the geometry of the elements
(positions and sizes) each element of the collection does.
Token List
Define a class (and interface) to represent a collection of token-objects (which
were defined in the token assignment). For now, make the collection a
history. Later you might need to modify the collection to implement some
extra credit features.
Main Class
Write a main class, using the conventions mentioned in earlier assignments,
to test all of the classes above. Execute this class to create console and
ObjectEditor windows demonstrating the correct behavior of these classes.
Constraints
As always, try and follow all style principles you have learned so far in
class, and use only the concepts seen in class so far, and specified in
earlier assignments. This means you cannot use the class Object in
the definition of your collection classes. You must carefully choose the
type of the element of each collection so that only legal objects in the
collection can be stored in it.
Questions to be answered
Answer the following questions:
Submission Instructions
Submit to blackboard your code together with screenshots of test cases and a
document identifying the extra credit features and containing the answer to
the questions