public class Olympics2
{
private int gold = 0;
private int silver = 0;
private int copper = 0;
public void changeModel(int a,int b,int c)
{
gold = a;
int silver = b;
int copper = 50;
System.out.println("In changeModel:"+"金牌="+gold+"银牌="+silver+"铜牌="+copper);
this.copper=c;
}
String getModel()
{
return"金牌="+gold+"银牌="+silver+"铜牌="+copper;
}
public static void main(String[] args)
{
Olympics2 o2 = new Olympics2();
System.out.println("Before changeModel:"+o2.getModel());
changeModel(100,100,100);
System.out.println("After changeModel:"+o2.getModel());
}
} |