// TIJ4 第2章 一切都是对象, 练习 11, 第 90 页;
// 将AllTheColorsOfTheRainbow这个示例改写成一个程序,然后编译、运行。
class AllTheColorsOfTheRainbow{
int anIntegerPepresentingColors = 0;
int hue = 0;
void changTheHueOfTheColor(int newHue){
this.hue = newHue;
}
void changColor(int newColor){
this.anIntegerPepresentingColors = newColor;
}
}
public class RainbowColorTest{
public static void main(String[] args){
AllTheColorsOfTheRainbow aCR = new AllTheColorsOfTheRainbow();
System.out.println("aCR.anIntegerPepresentingColors = "+ aCR.anIntegerPepresentingColors);
System.out.println("aCR.hue = "+ aCR.hue);
aCR.changTheHueOfTheColor(75);
aCR.changColor(12);
System.out.println("通过aCR对象调用AllTheColorsOfTheRainbow类的方法");
System.out.println("aCR.anIntegerPepresentingColors = "+ aCR.anIntegerPepresentingColors);
System.out.println("aCR.hue = "+ aCR.hue);
}
}