|
|
Homework #4Due: Online by Wednesday, February 18, by 9:00 p.m. No late asssignments will be accepted.For this assignment, design and implement the classes described in the following problems. When you are done, you should turn in the Java source files electronically over the web. 0. Download the skeleton files for the homework from here. 1. Many computer systems are used to model moving objects. Objects in motion have a direction and a speed. These qualities can be modeled using a velocity vector that has a direction and a length. In this problem you will implement a new class Velocity that can be used to model a changing velocity vector. Implement the constructor and all the following methods. Read the javadoc specification for this class (provided to you in the download file) for details of the implementation. The specific formulas that you need are given in the specification.
2. Further operations that you might need for Velocity vectors are rotate() (a command) and magnitude() (a query). Implement the following two methods in your Velocity class. Again, the specific calculations that you need are given in the specification.
3. You have been provided with a simple Rock class. It models a rock that has a mass. The only thing that you can do with these Rocks is ask them how much their mass is using the getMass() method. We will imagine that these rocks are on Mars and that our job is to carry them around with a Rover. Your task is to write a class Rover that has a certain carrying capacity and whose method verifyLoad() can take an ArrayList of Rocks and verify that it can carry the rocks without exceeding its capacity. This is a simple task, it is not a trick question. See the specification for a little more detail on the implementation.
4. You have been provided with a simple BirdFeeder class. A BirdFeeder contains a certain amount of food, and it should have a method feedTheBirds(int serving)that counts how many birds could be fed using a particular serving size. Your task is to implement that method. Be sure to read the method details in the specification carefully.
5. You have been provided with a simple Car class that models cars with a brand name and a model year. Your task is to write a ParkingLot class that can manage a list of Cars, adding and removing them from a parking lot. It has an infinite number of parking spots, but it's a little inconvenient to use because the most recent Car to arrive is the only one that can leave. After it is gone, then the Car that arrived before it can leave, and so on. Thus, the first Car to arrive cannot leave until all other Cars have left. Read the method details in the specification to fully understand the operation of the class. a. Implement:
b. Implement:
What to Turn InUse the this online turnin form to turn in the files containing the Java classes that give your solution to these problems.
|