実験課題4
Exercise 4(課題4) See the section 3.5.1. "Coupling". Improve isJidou and calculateBMIorRohrer methods that have a common coupling in below figures. calculateBMIorRohrer method calculates Body Mass Index or Corpulence(Rohrer's) Index. Follow the instructions below to explain. Hint. the variable with a prefix public static is a kind of global variable.
- create the Java application project named
chapter3kadai4. - create
mainmethod to run the program described as below figures in the project class. - modify the program to decrease the coupling.
public static boolean isBmi = false;
public static boolean isJidou(int age) {
int chugaku_age = 16;
if (age <= chugaku_age) {
isBmi = false;
return true;
} else {
isBmi = true;
return false;
}
}
public static double calculateBMIorRohrerIndex(double weight, double height) {
if (isBmi) {
return weight/(height*height);
} else {
return 10.0*weight/(height*height*height);
}
}
(3.5.1.節をよく読み、プロジェクトchapter3kadai4を作成し、共有結合となっている下図のソースコード中の2つのメソッドisJidouとcalculateBMIorRohrerを改善しなさい。なおcalculateBMIorRohrerIndexメソッドはボディマス指数またはローレル指数を計算する。)