Assignment 6 - FSDT (1)

.docx

School

Lambton College *

*We aren’t endorsed by this school

Course

2013

Subject

Industrial Engineering

Date

Apr 3, 2024

Type

docx

Pages

3

Uploaded by MajorThunder13643

Report
CSD_3464 PROGRAMMING JAVA SE Assignment#6 1. Car Instrument Simulator program © 2022 LAMBTON COLLEGE IN TORONTO
CSD_3464 PROGRAMMING JAVA SE For this assignment, you will design a set of classes that work together to simulate car’s fuel gauge and odometer for two cars. The classes you will design are the following: The Fuel Gauge Class: This class will simulate a fuel gauge. Its responsibilities are as follows: • To know the car’s current amount of fuel, in liters. • To report the car’s current amount of fuel, in liters. • To be able to increment the amount of fuel by 1 liter. This simulates putting fuel in the car. (The car can hold a maximum of 15 liters .) • To be able to decrement the amount of fuel by 1 liter, if the amount of fuel is greater than 0 liters. This simulates burning fuel as the car runs. The Odometer Class: This class will simulate the car’s odometer. Its responsibilities are as follows: • To know the car’s current mileage. • To report the car’s current mileage. • To be able to increment the current mileage by 1 kilometer. The maximum mileage the odometer can store is 999,999 kilometers. When this amount is exceeded, the odometer resets the current mileage to 0. • To be able to work with a Fuel Gauge object. It should decrease the Fuel Gauge object’s current amount of fuel by 1 liter for every 24 kilometers traveled. (The car’s fuel economy is 24 kilometers per liters.) Demonstrate the classes by creating instances of each. Simulate filling the car up with fuel, and then run a loop that increments the odometer until the car runs out of fuel. During each loop iteration, print the car’s current mileage and amount of fuel. © 2022 LAMBTON COLLEGE IN TORONTO
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help