9.0k views
2 votes
Suppose you create a new PricedApt class that is derived from the RentalApt class (so it's derived from a derived class). It adds one new double attribute, price, which tells what the monthly rental for the apartment is. Here is a constructor call for the class: PricedApt p = new PricedApt("jill", 900, true, "jack", 1050.00); The class is missing its constructor. In the box provided below, write the constructor in its entirety. public class PricedApt extends RentalApt { private double price;

User Bdkosher
by
6.6k points

1 Answer

5 votes

// here i am writing C++ code

public class PricedApt extends RentalApt {

private double price;

RentalApt(firstname,price,b,lastname): PricedApt(firstname,b,lastname){

// As there is only one member in this class this means that every argument //coming to it is supposed to be passed to the parent class constructor.

// in c++ : operator is used to call the super class constructor

this.price = price;

}

}

User Oreh
by
6.3k points