Homework Assignment Chapter 10b Create a new Java Project named Chap10b Create a class named Vehicle that acts as a superclass for vehicle types. The Vehicle class contains private data fields for the number of wheels and the average number of miles per gallon. The Vehicle class contains getters and sette for the data fields. The Vehicle class also contains a constructor receiving intege parameters for the number of wheels and average miles per gallons, and a display() method that prints the required output (use get methods). Create two subclasses, Car and MotorCycle, that each extend the Vehicle class. Each subclass contains a constructor that accepts the miles-per-gallon value as a argument and forces the number of wheels to the appropriate value-2 for a MotorCycle and 4 for a Car. Use the superclass constructor to set the wheels and mpg data fields (use the super keyword). Write a UseVehicle class to instantiate one object of each subclass and calls the displa method to print the object's values. Save the files as Vehicle.java, Car.java, MotorCycle.java, and UseVehicle.java For reference, see page 490-491. Zip the folder Chap10b and upload. Make sure your code has the following comments at the beginning of each file with the appropriate information: //Filename //Author //Date Console Output: LWhoolc: 4 Mng: 20

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Homework Assignment Chapter 10b
Create a new Java Project named Chap10b
Create a class named Vehicle that acts as a superclass for vehicle types.
The Vehicle class contains private data fields for the number of wheels and the
average number of miles per gallon. The Vehicle class contains getters and setters
for the data fields. The Vehicle class also contains a constructor receiving integer
parameters for the number of wheels and average miles per gallons, and a
display() method that prints the required output (use get methods).
Create two subclasses, Car and MotorCycle, that each extend the Vehicle class.
Each subclass contains a constructor that accepts the miles-per-gallon value as an
argument and forces the number of wheels to the appropriate value-2 for a
MotorCycle and 4 for a Car. Use the superclass constructor to set the wheels and
mpg data fields (use the super keyword).
Write a UseVehicle class to instantiate one object of each subclass and calls the display
method to print the object's values.
Save the files as Vehicle.java, Car.java, MotorCycle.java, and UseVehicle.java
For reference, see page 490-491.
Zip the folder Chap10b and upload.
Make sure your code has the following comments at the beginning of each file
with the appropriate information:
//Filename
//Author
//Date
Console Output:
Car--> Wheels: 4 Mpg: 30
MotorCycle--> Wheels: 2 Mpg: 60
Transcribed Image Text:Homework Assignment Chapter 10b Create a new Java Project named Chap10b Create a class named Vehicle that acts as a superclass for vehicle types. The Vehicle class contains private data fields for the number of wheels and the average number of miles per gallon. The Vehicle class contains getters and setters for the data fields. The Vehicle class also contains a constructor receiving integer parameters for the number of wheels and average miles per gallons, and a display() method that prints the required output (use get methods). Create two subclasses, Car and MotorCycle, that each extend the Vehicle class. Each subclass contains a constructor that accepts the miles-per-gallon value as an argument and forces the number of wheels to the appropriate value-2 for a MotorCycle and 4 for a Car. Use the superclass constructor to set the wheels and mpg data fields (use the super keyword). Write a UseVehicle class to instantiate one object of each subclass and calls the display method to print the object's values. Save the files as Vehicle.java, Car.java, MotorCycle.java, and UseVehicle.java For reference, see page 490-491. Zip the folder Chap10b and upload. Make sure your code has the following comments at the beginning of each file with the appropriate information: //Filename //Author //Date Console Output: Car--> Wheels: 4 Mpg: 30 MotorCycle--> Wheels: 2 Mpg: 60
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY