Question
Write the following program in Java. Create an abstract Vehicle class - Vehicle should have a float Speed and string Name, an abstract method Drive,
Write the following program in Java.
Create an abstract Vehicle class
- Vehicle should have a float Speed and string Name, an abstract method Drive, and include a constructor.
Create a Tesla class
- Tesla inherits from Vehicle.
- Tesla has an int Capacity.
- Include a constructor with the variables, and use super to set the parent class members.
- Override Drive to increase the speed by 1 each time.
- Add a toString to print the name, speed, and Capacity as shown:
Name: Model X
Speed: 1.0
Capacity: 100
Create a Client that does the following:
- Create a Tesla
- Drive it one time
- Print out the Name, Speed, Capacity
- Drive it one more time
- Print out the Name, Speed, Capacity again
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started