Java Reference
In-Depth Information
to be added to, removed from, or searched for in the cart. The cart should be able to report the total price of all item
orders it currently carries.
2. Write a program to reverse the lines of a file and also to reverse the order of the words in each line of the file. Use
ArrayList s to help you.
3. Write a family database program. Create a class to represent a person and to store references to the person's mother,
father, and any children the person has. Read a file of names to initialize the name and parent-child relationships of
each Person . (You might wish to create a file representing your own family tree.) Store the overall list of Person s
as an ArrayList . Write an overall main user interface that asks for a name and prints the maternal and paternal
family line for that person.
Here's a hypothetical execution of the program, using as an input file the line of English Tudor monarchs:
Person's name? Henry VIII
Maternal line:
Henry VIII
Elizabeth of York
Paternal line:
Henry VIII
Henry VII
Children:
Mary I
Elizabeth I
Edward VI
4. Write a class that models a list of possibly overlapping rectangular two-dimensional window regions, like the windows
for the programs open on your computer. The order of the rectangles in the list implies the order in which they would
display on the screen (sometimes called the “ z -order”), from 0 on the bottom to size() - 1 on the top.
Each rectangle stores its ( x, y ) position, width, and height. Your rectangle list class should have a method that takes a
Point as a parameter, treats it as though the user clicked that Point on the screen, and moves the topmost rectangle
touching that Point to the front of the list.
Search WWH ::




Custom Search