hiya mandy,
I have a program here that may help to understand inheretence a little more .The property class is abstract and is the super class.notice the public void door() method ,it is declared in property but not in the two subclasses,this is becuase it is inhereted from property,so in a main method if you were to say
Shed s = new Shed();
s.doors();
This would work becuase method doors is inhereted from property and does not need to be specified in shed.
bungalow IS A property .shed IS A property. each method in bungalow and shed overrides the methods in property and implements them .notice that bumgalow implements interface brickwork you can use interfaces to implement uncommon methods between subclasses the same applys to shed and it`s wooden interface.I realise this is a million miles away from your problem but looking at it from a different perspective may help and I hope it does.Heres the program[code]
abstract class Property
{
public void doors()
{
input = JOptionPane.showInputDialog("Please enter doors in shed");
noOfDoors=input;
}
public abstract void windows();
public abstract void rooms();
}
class Bungalow extends Property implements BrickWork
{
private
String noOfDoors;
private String noOfWindows;
private String noOfRooms;
private String input;
private int qty;
private int sqMeters;
public Bungalow()
{
this.input=input;
this.qty=qty;
this.sqMeters=sqMeters;
}
public void windows()
{
input = JOptionPane.showInputDialog("Please enter Windows in Bungalow");
noOfWindows=input;
}
public void rooms()
{
input = JOptionPane.showInputDialog("Please enter Rooms in bungalow");
noOfRooms=input;
}
public void noOfBricks(int sqMeters)
{
this.sqMeters=sqMeters;
qty=0;
if(sqMeters<=5)
{
qty=lowNoOfBricks;
}
else if(sqMeters<=10)
{
qty=medNoOfBricks;
}
else qty=highNoOfBricks;
}
}
class Shed extends Property implements Wooden
{
private String noOfDoors;
private String noOfWindows;
private String noOfRooms;
private String input;
private int qty;
private int sqMeters;
public Shed()
{
this.input=input;
this.qty=qty;
this.sqMeters=sqMeters;
}
public void windows()
{
input = JOptionPane.showInputDialog("Please enter windows in shed");
noOfWindows=input;
}
public void rooms()
{
input = JOptionPane.showInputDialog("Please enter rooms in shed");
noOfRooms=input;
}
public void woodQty(int sqMeters)
{
this.sqMeters=sqMeters;
qty=0;
if(sqMeters<=2)
{
qty=lowQtyWood;
}
else if(sqMeters<=6)
{
qty=medQtyWood;
}
else
qty=highQtyWood;
}
}
interface Wooden
{
static final int lowQtyWood=7;
static final int medQtyWood=20;
static final int highQtyWood=30;
public void woodQty(int sqMeters);
}
interface BrickWork
{
static final int lowNoOfBricks=1000;
static final int medNoOfBricks=2000;
static final int highNoOfBricks=3000;
public void noOfBricks(int sqMeters);
}[\code]
by the way for obvious reasons this code wont run as there is no main method .hope it helps though