
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The tasks for homework 2 in the eecs 368 programming language paradigms course during the fall semester of 2007. Students are required to modify their existing shape and composite shape classes to implement interfaces and collections, as well as add new methods. The objective is to gain experience using built-in java interfaces, classes, and methods.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

This homework involves minor modifications to your solution to Homework 1. Although there are multiple problems assigned, you may submit a single program that solves all of them. None of these problems is difficult. Problem 1: Modify your Shape class to implement the Comparable interface. One shape should be smaller than another if its area is smaller. Problem 2: Modify your Composite shape class to use one of the Collection interfaces ( List , Set , Map , etc.) to store its internal collection of shapes. Think carefully about what properties you want your internal collection to have when you select the interface to implement. Problem 3: Modify your Composite shape class to use built in static methods from the Collections class to implement methods to sort the list and find the smallest and largest shape. Your sort method should produce a list ordered from smallest area to largest area. Problem 4: Modify your area and perimeter methods for composite shapes to use an iterator to step through the collection of shapes. Problem 5: Add a method to extract all Circle objects from the collection of shapes comprising a Composite shape. Use static methods from Collections if possible. Problem 6: Define a new abstract method in your Shape class called scale that takes a single value of type double and scales a shape proportionally by that amount specified. For Rectangle, Square, and Circle , the scale method multiplies side length or radius by the specified amount. For Composite shapes, each shape references by the shape should be scaled. Use an iterator to implement this method. Notes: The objective of this homework is to start using built-in Java interfaces, classes and methods. Necessary classes are well documented on the Java site linked to the course web site. Please remember to provide test methods where needed to demonstrate your code.