ICS 22
Homework 4
Due 10/26
- Reminder: we check for cheating (via copying) and all students involved with get a grade of zero for this homework.
- (50 points) Picture. Write a program that stores various Shapes in a Picture and allows the user to add shapes and print the picture.
- Design. You get to design this one, but be sure you implement your Picture as an ArrayList of Shapes. (Hint: class Shape is abstract and the specific Shapes are subclasses of Shape.)
- Define three types of Shapes: Diamond, Square, and Triangle. Different Shapes will have different algorithms for drawing. Use simple character graphics for now similar to what I put in the code. You can make them print proportional to their size if you want.
- I sketched out a start for this program in ShapeTest.java available via my web site under homework starts.
- (50 points) Petting Zoo. Write a program that stores various animals in a petting zoo and allows the user to feed and pet the animals.
- Design. You get to design this one, but be sure you implement your Zoo as a LinkedList of Animals. (Hint: abstract class is Animal and the specific animals are subclasses of Animal.)
- Define five types of animals: Anteater, Bear, Cat, Dog, and Goat. You can add an animal to the petting zoo, try to feed a specific food to all the animals in the zoo, or try to pet all the animals in the zoo. Different animals will have different behaviors depending on what you try to feed them. Some might do nothing when offered a particular food. They will also behave differently when petted. You can be creative here or just follow what we have done in the sample. The possible foods are ants, beef, grain, honey, and tuna. Define them as Strings.
- For each of your programs, provide a text-based menu interface similar to what you did for homework 1 that allows all of the operations on the zoo and picture.