Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.Write an abstract class Vehicle which has two data fields: speed(int) and costPerKM(double), get/set methods for each data field and a constructor method that initializes

2.Write an abstract class Vehicle which has two data fields: speed(int) and costPerKM(double), get/set methods for each data field and a constructor method that initializes speed to 0 and costPerKM to 0.0. The vehicle class also has an abstract method getTripDuration() that has a double type parameter(for the trip distance) and return type is also double.

3. write a child class of vehicle named Plane which has a data fieild extraCost(double) and the corresponding get/set methods. The plane calss has two construtor method: a default constructor tht set/initialize speed to 0, costPerKM to 0.0, and the other constructor sets/initialize the three data fields with the corresponding paramenteres. The Plane class has another method named getCost() that has one double type parameter for the distance and retutrns the trip cost by taking a plane i:e cost=costPerKm*distance+extraCost. The class implements the getTripDuration() method that calcuklates the trip duration by adding half an hour(for taking off, landing etc.) to the normal flight duration(distance divided by speed).

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

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago