Skip to content

Instantly share code, notes, and snippets.

@takuma7
Created December 16, 2011 02:11
Show Gist options
  • Save takuma7/1484106 to your computer and use it in GitHub Desktop.
Save takuma7/1484106 to your computer and use it in GitHub Desktop.
abstract class Arbeit{
int kingaku=0;
abstract void calc(int hour);
void hyouji(){
System.out.println("got " + kingaku + " yen.");
}
}
class Convenience extends Arbeit{
void calc(int hour){
System.out.println("worked " + hour + " hour(s) at a convenience store.");
kingaku += hour*1000;
}
}
class CDshop extends Arbeit{
void calc(int hour){
System.out.println("worked " + hour + " hour(s) at a CD shop.");
kingaku += hour*850;
}
}
class GasStation extends Arbeit{
void calc(int hour){
System.out.println("worked " + hour + " hour(s) at a gas station.");
kingaku += hour*1000 + 500;
}
}
class Mondai14_2{
public static void main(String[] args){
GasStation gs = new GasStation();
Convenience cv = new Convenience();
CDshop cd = new CDshop();
gs.calc(3);
cv.calc(4);
cd.calc(2);
cd.hyouji();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment