Problems

  1. MotorBoat Class (25 points)

    Exercise 5.7 (p 359): Implement a class MotorBoat that represents motorboats. A motorboat has attributes for:

    • The capacity of the fuel tank
    • The amount of fuel in the tank
    • The maximum speed of the boat
    • The current speed of the boat
    • The efficiency of the boat's motor
    • The distance traveled
    The class has methods to
    • Change the speed of the boat
    • Operate the boat for an amount of time at the current speed
    • Refuel the boat with some amount of fuel
    • Return the amount of fuel in the tank
    • Return the distance traveled so far
    If the boat has efficiency e, the amount of fuel used when traveling at a speed s for time t is e x s^2 x t. The distance traveled in that time is s x t.

    Include a driver program that instantiates several objects of type MotorBoat and demonstrates the class.

  2. PersonAddress Class (20 points)

    Exercise 5.8 (p 330): Implement a class PersonAddress that represents an entry in an address book. Its attributes are:

    • The first name of the person
    • The last name of the person
    • The email address of the person
    • The telephone number of the person
    It will have methods to
    • Access each attribute
    • Change the email address
    • Change the telephone number
    • Test whether two instances are equal based solely on name
    Include a driver program that instantiates several objects of type PersonAddress and demonstrates the class.

Submitting Your Problem Set

You should submit all problems for grading by the deadline (see class schedule for date). To submit a program, you need to demonstrate (during office hours or lab) your program and explain how it works.