Power java 11장 Programming 2번문제 풀이

Posted by 알 수 없는 사용자
2016. 4. 12. 15:47 Java/PowerJava 문제풀이

※ 문제풀이는 작성자 본인이 직접 한것이므로 정답이 아닐 수 있습니다.

   혹시 보시고 틀린 부분이 있으면 알려주시기 바랍니다.

 문제는 책을 참고하시기 바랍니다.

2번 문제풀이

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package day09;
 
class Person{
    private String name,addr,phone;
    public Person() {
        
    }
    public Person(String name, String addr, String phone){
        this.name = name;
        this.addr = addr;
        this.phone = phone;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddr() {
        return addr;
    }
    public void setAddr(String addr) {
        this.addr = addr;
    }
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }
    
}
class Customer extends Person{
    String custom_num;
    int mileage;
    
    public Customer() {
        
    }
    public Customer(String custom_num,int mileage){
        super();
        this.custom_num = custom_num;
        this.mileage = mileage;
    }
}
 
 
public class Programming11_2 {
    public static void main(String[] args) {
        Person p1 = new Person("김씨""김주소"    , "010-3232-0322");
        Customer c1 = new Customer("1번고객"2323);
        
        System.out.println("이름 : "+p1.getName());
        System.out.println("주소 : "+p1.getAddr());
        System.out.println("전화번호 : "+p1.getPhone());
        System.out.println("고객번호 : "+c1.custom_num);
        //private와 public의 차이를 보기위하여 p1,c1의 차이를 두었다.
        System.out.println("마일리지 : "+c1.mileage);
        
    }
    
}
 
 
cs