Question: Assignment 4 : Write a Java class named ` Car ` based on the provided ` CarTester . java ` . Requirements for the `
Assignment : Write a Java class named Car based on the provided CarTesterjava
Requirements for the Car class:
Create a Java class named Car
Implement instance variables for the following properties:
carName,
mileage
fuelTankCapacity
gasLevel
You need to figure out the data types of these variables based on CarTester.java
Implement the following methods
default construcgtor
overloaded construcgtor
setters
getters
toString
Implement the following additional methods:
drivedistance: This method should allow the car to drive the specified distance. If there's not enough gas, the car should
stop after traveling as much distance as possible.
canDrivedistance: This method should return true if the car can drive the given distance with the current gas level,
otherwise false
fillGasx: This method should fill the car's gas tank with the specified amount x The method should ensure that x does
not exceed the available space in the fuel tank and should not allow overflowing.
Once you have implemented the Car class, test it using the provided CarTesterjava
Please do not change CarTester.java
Your Car.java should work with the CarTester.java I provided. Otherwise, you will not earn any credit.
Capture the output produced by CarTesterjava in a file named CarTesteroutput.txt
Note: Ensure that the output file CarTesteroutput.txt contains the output exactly as produced by running
CarTesterjava
Evaluation:
Method or Criteria Points
Default constructor
Overloaded constructor
Setters
Getters
toString method
drive method
canDrive method
fillGas method
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
