Hello,
I am a beginner of Java.
I made this code but I think this code may be shorter.
Could you help me?
----
abstract class Shain{
public abstract int getKyuuyo();
}
class Maneijya extends Shain{
private int koteikyu =1000000;
public int getKyuuyo(){
return koteikyu;
}
}
class Purogurama extends Shain{
private int kihonkyu1=350000;
private int jikankyu1=2000;
private int zangyouJikan1=10;
private int ptotal1=kihonkyu1+jikankyu1*zangyouJikan1;
private int kihonkyu2=250000;
private int jikankyu2=1500;
private int zangyouJikan2=20;
private int ptotal2=kihonkyu2+jikankyu2*zangyouJikan2;
public int getKyuuyo(){
return ptotal1+ptotal2;
}
}
class Arubaito extends Shain{
private int jikankyu1=1200;
private int zangyouJikan1=120;
private int atotal1=jikankyu1*zangyouJikan1;
private int jikankyu2=1000;
private int zangyouJikan2=150;
private int atotal2=jikankyu2*zangyouJikan2;
public int getKyuuyo(){
return atotal1+atotal2;
}
}
class KyuyoCal{
public static void main(String args[]){
Maneijya m=new Maneijya();
Purogurama p=new Purogurama();
Arubaito a=new Arubaito();
System.out.println("給与の合計は、"+(m.getKyuuyo()+p.getK yuuyo()+a.getKyuuyo())+"です。");
}
}