Question: Using Java, create two classes: BuildCar class and MyCarApp class. BuildCar is the blueprint class used to build car objects. The BuildCar class should have

Using Java, create two classes: BuildCar class and MyCarApp class. BuildCar is the blueprint class used to build car objects. The BuildCar class should have instance variables for: Speed, Odometer, Direction, and Fuel_gauge. You can create additional instance variables if you like. Your class should include methods to: accelerate (hitGas), break (hitBreak), change directions (turn right, turn left), add miles on a trip (addMiles), and add fuel (checkFuel). All Instance variables will start at zero.
Your Main method in the MyCarApp class will need to create two BuildCar objects and take each car on a different trip. The fuel economy is 20 miles to the gallon for both cars. Using the methods in the BuildCar class, take each car on a road trip of at least 200 miles. Output the following: Each time you change direction (turnLeft, turnRight) this becomes another leg of the trip and you should (1) change the speed (hitBreak or hitGas),(2) add the number of miles in that direction (addMiles), and (3) check to see if you need more fuel (use checkFuel). At the end of each trip, you should be able to output the number of legs to your trip, the total miles travelled (use checkMiles), the amount of fuel used, and the direction you are heading.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!