Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me with this java code CS1180 Lab 10 Inheritance This lab will give you an opportunity to explore the use of inheritance.

Can you help me with this java code image text in transcribed
image text in transcribed
image text in transcribed
CS1180 Lab 10 Inheritance This lab will give you an opportunity to explore the use of inheritance. This lab involves two classes, a Vehicle class which will be the base class for a GasGuzzler class. There is no I/O in either of these classes. There will also be a test class. The Vehicle class contains properties and methods that are common to all vehicles. This class contains two specific properties-speed- the rate at which the vehicle is traveling in miles/hour, and- weight-the weight of the vehicle in pounds. The Vehicle class has the following public methods: . Vehicle objects can be constructed 2 different ways: by specifying the weight and the speed, or by specifying the weight only in which case the speed defaults to 0. 2. There are accessor (getter) methods for both weight and speed. There are no setter methods. 3. The speedup method takes 1 parameter, the amount to increase speed by, and returns the new speed of the vehicle. The increase must be positive to have any affect. 4. The slowdown method takes 1 parameter, the amount to decrease the speed by, and returns the new speed of the vehicle-which can NEVER be a negative number! The decrease must be positive to have any affect. s. The brake method sets the speed to 0, and returns nothing. 6. The mom entum method returns the calculated momentum of the vehicle. The formula for calculating momentum is: weight 0.4536 *speed 0.447 7. The toString method should return a string indicating the weight of the vehicle, the current speed of the vehicle, and the momentum of the vehicle. Each piece of information should appear on a line by itself. A GasGuzzler IS A Vehicle, so the GasGuzzler class inherits from the Vehicle class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 2 Lnai 6322

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215882X, 978-3642158827

More Books

Students also viewed these Databases questions

Question

Describe the job youd like to be doing five years from now.

Answered: 1 week ago

Question

So what disadvantages have you witnessed? (specific)

Answered: 1 week ago