OOP - Assignment 2

Topic: Auto mileage

Points: 25

Due: 9-9-2003 at class time

Instructor: Dana Steil

Turn In: C++ Files

Auto.h, Auto.cpp and Assignment1.cpp on

C# Files

Auto.cs and Assignment1.cs

Java Files

Auto.java and Assignment1.java


C# and Java Console Help From McCown


Expected review Material:

  1. Class definition
  2. Object instantiation
  3. Private vs. Public members and functions
  4. Console IO and IO manipulation
  5. Use of constants
  6. Good variable and function names
  7. Case insensitive character comparison


Expected new material:

  1. Namespacing (any standard library that you need to include should use the namespace method, not the entire header file)
  2. Default arguments
  3. Function overloading
  4. Reading a UML Diagram
  5. Compiler Directives (#ifndef, #define, #endif)


General Overview:

Given general automobile specifications, this application will keep track of remaining fuel, trip miles, and total miles.


Test Program: (5 points)


Filename: Assignment1.cpp, Assignment1.cs, Assignment1.java


Write a test program for each of the Autos classes functionality in C++, C#, and Java


CAuto Header File (C++ Only):

File Name: Auto.h


Use Compiler Directives to keep CAuto from possibly being defined twice.





CAuto Method Details: (20 Points)

Filename: Auto.cpp, Auto.cs, Auto.java


CAuto() the default constructor for the CAuto class should request from the user initial values for each of the member variables. You may format this as you wish but the information must be entered in the order shown below.

Please enter the following auto information:

Make >Ford

Model >F-150

Year >89

Total Miles on Automobile >58000

Miles Per Gallon >22

Maximum Gallons Of Fuel In Tank >30

Gallons Of Fuel In Tank >10


void Drive(float Miles = 1) will move the car the specified number of miles. The total miles should be updated as well as the gallons of fuel in the tank. The drive function will be called with one argument in some cases and in others with no arguments.


void AddFuel() should completely fill the fuel tank of the automobile.


void AddFuel(float GallonsAdded) - should add the specified number of gallons to the fuel tank. If the specified number of gallons cannot fit in the fuel tank, a polite error message should be presented to the user and the tank should be filled completely.


void ResetTripMeter() Sets the trip miles to 0.


void Show() should display all of the information about the automobile in a simple concise manor. For example:

The 89 Ford F-150 currently has:

58059 miles on the odometer,

59 miles on the trip meter,

Gets 22 Miles Per Gallon,

and has 7.31818 out of a possible 30 gallons in the Fuel tank.