package ch05.object;
public class Value {
private int x;
private float y;
private char a;
private String b;
public void input(int x, float y, char a, String b) {
this.x=x;
this.y=y;
this.a=a;
this.b=b;
}
public void apple(int su) {
x+=su;
System.out.println(x);
}
public void banana(float su) {
y+=su;
System.out.println(y);
}
public void sub(int su, float num) {
x+=su;
y+=num;
System.out.println(x + " " + y);
}
//함수중복을 사
public void calc(int su) {
x+=su;
System.out.println(x);
}
public void calc(float su) {
y+=su;
System.out.println(y);
}
public void calc(int su, float num) {
x+=su;
y+=num;
System.out.println(x + " " + y);
}
public void disp() {
System.out.println(a + " " + b);
}
}
package ch05.object;
public class Exam42 {
public static void main(String[] args) {
Value v=new Value();
v.input(10, 22.2f, 'A', "apple");
v.apple(77);
v.banana(11.1f);
v.sub(2, 33.3f);
System.out.pritnln();
v.calc(77);
v.calc(11.1f);
v.calc(2, 33.3f);
}
}
87
33.300003
89 66.600006
166
77.700005
168 111.0