Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this lab, we provide a complete class that simulates a simple car. Review the code in SimpleCarjava below.Click on the orange Main.java link to

image text in transcribedimage text in transcribedimage text in transcribed

For this lab, we provide a complete class that simulates a simple car. Review the code in "SimpleCarjava" below.Click on the orange Main.java" link to toggle to the other file. Then complete "Main.java" to create an object and perform several operations as indicated in the FIX ME comments. LAB ACTITY 5.17.1: zyLab: Simple Car Current file: Mai...ava Load default template... 1 public class Main 2 public static void main(String args) FIX ME: define and instantate a SimpleCar object // FIX ME invoke drive to drive 100 miles //FIX ME: invoke reverse to back up 4 miles /7FIX ME: invoke honkHorn 4 7 10 FIX ME: invoke reportO to display the car status 12 13 14 File is marked as read only Current file: SimpleCar.java 2 Simulates a simple car with operations 3 to drive and check the odometer 4 5 @author Scott Grissom 7 public class SimpleCar f 9 /** number of miles driven* private int miles; 10 13 Constructor sets inventory to 20 15 public SimpleCar 16 17 18 miles 0 20 Drive forward 21 @param distance to drive 23 public void drive(int dist) 24 25 26 miles miles dist; 28 Drive backwards 29 @param distance to drive 31 32 public void reverse(int dist)f miles miles -dist 34 36 @returns number of miles driven 38 public int getOdometerO 39 40 return miles; 43 honks the horn 45 public void honkHorn 46 47 System.out.printlnC"beep beep"); 50 Report car status 52 public void reportOi 53 54 System.out.println("Car has driven: " miles); 57 This method must be here for testing only 59 public static void main(String[ args) f 60 61 62 63

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions