Hi all,
I'm almost done with a problem for a java class I'm taking. The chapter I'm studying is on inheritance and I think I understand it ok. The parent class will compile fine, but when the child class tries to compile I get an error saying it cannot find the constructor in the parent class.
I am supposed to write an application that creates an object of each class, and demonstrate that all the methods work correctly.
Take a look, any input would be VERY appreciated!
Parent Class:
public class HotelRoom
{
double rentRate;
int roomNum;
public HotelRoom(int num)
{
roomNum = num;
if(roomNum < 300)
rentRate = 69.95;
else
rentRate = 89.95;
}
public double getRentRate()
{
return rentRate;
}
public int getRoomNum()
{
return roomNum;
}
}
Child Class:
public class Suite extends HotelRoom
{
public Suite(int num)
{
roomNum = num;
if(roomNum > 500)
rentRate += 40.00;
}
}
Demo Class:
public class UseHotelRoom
{
public static void main(String[] args)
{
HotelRoom guestRoom = new HotelRoom(100);
Suite isSuite = new Suite(600);
System.out.println("Your hotel room number is " +
guestRoom.getRoomNum() + "\nThe total comes to $" +
guestRoom.getRentRate());
System.out.println("Your hotel room number is " +
isSuite.getRoomNum() + "\nThe total comes to $" +
isSuite.getRentRate());
}
}