Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Last active December 17, 2015 20:29
Show Gist options
  • Save jpotts18/5667670 to your computer and use it in GitHub Desktop.
Save jpotts18/5667670 to your computer and use it in GitHub Desktop.
Inheritance, abstract, interface
public class Bathroom extends Room implements Flushable{
// inherited attr
// length
// width
public double bathtub = 0.5;
public boolean hasShower;
@Override
public int getArea(){
// can be overridden?
}
// inherited from Flushable
public void flush(){
}
public void plunge(){
}
public void callOutForToiletPaper(){
}
}
public class Building{
// class variables
Door mFrontDoor
Door mLastDoor
String mAddress
// overloaded constructors
public Building(){
}
public Building(String address){
mAddress = address;
}
// accessors
public getAddress(){
return mAddress;
}
public setAddress(String address){
mAddress = address;
}
}
public interface Flushable{
public void flush(){}
public void plunge(){}
public void callOutForToiletPaper(){}
}
public class House extends Building{
// constants
Room mLivingRoom
List<Bathoom> mBathrooms = ArrayList<Bathroom>();
// constructor
public House(){}
public List<Bathroom> getBathrooms(){
return mBathrooms;
}
}
abstract public class Room{
int mLength
int mWidth
Room(){}
Room(int length, int width){
mLength = length;
mWidth = width;
}
public int getArea(){
return mLength * mWidth
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment