/** Represents a car. */ public class Car // TODO: Inherit from Vehicle { // Do NOT add any instance variables public Car(double purchasePrice) { // TODO: Complete } // TODO: Override the getValue method
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
/**
Represents a car.
*/
public class Car // TODO: Inherit from Vehicle
{
// Do NOT add any instance variables
public Car(double purchasePrice)
{
// TODO: Complete
}
// TODO: Override the getValue method
Description:
In the constructor of Car class, call the superclass constructor with the purchasePrice as the argument.
- In the getValue function, do the following:
- Initialize a variable.
- Set the value of the variable to super.getValue() - ((super.getMileage() / 10000) * 2500).
- If the value of the variable is less than 0, set its value to 0.0.
- Return the value of the variable.
Implementation of the Car class is given in the next step.
Step by step
Solved in 3 steps with 1 images