Java 【メソッド・クラス】
public class KadaiCalculationMain {
public static void main(String[] args) {
KadaiCalculationProcessing kcm = new KadaiCalculationProcessing();
kcm.Calculate(8, 4, 1, 81);
int valueAdd = kcm.valueAdd();
System.out.println(valueAdd);
int valueSub = kcm.valueSub();
System.out.println(valueSub);
int valueMul = kcm.valueMul();
System.out.println(valueMul);
double valueDiv = kcm.valueDiv();
System.out.println(valueDiv);
}
}
と、
public class KadaiCalculationProcessing {
int Addition, Decrease, Multiplication;
double Exclusion;
public void Calculate(int num1, int num2, double num3, double num4) {
Addition = num1 + num2;
Decrease = num1 - num2;
Multiplication = num1 / num2;
Exclusion = num3 / num4;
}
int valueAdd() {
return Addition;
}
int valueSub() {
return Decrease;
}
int valueMul() {
return Multiplication;
}
double valueDiv() {
return Exclusion;
}
}
で、フィールド変数を使用せず、メソッドの引数に値を渡す場合はどうすれば良いのでしょうか?
0