은근한

자바 신용카드 상속 예제 본문

카테고리 없음

자바 신용카드 상속 예제

EsJoo 2014. 5. 18. 21:46

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
package Card;
public class CreditCard{
    private String Cnumber;
    private String Owner;
    private int Point;
    private int Pay;
    private int Balance =0;
    public String getCnumber() {
        return Cnumber;
    }
    public void setCnumber(String cnumber) {
        Cnumber = cnumber;
    }
    public String getOwner() {
        return Owner;
    }
    public void setOwner(String owner) {
        Owner = owner;
    }
    public int getPoint() {
        return Point;
    }
    public void setPoint(int point) {
        Point = point;
    }
    public int getPay() {
        return Pay;
    }
    public void setPay(int pay) {
        Pay = pay;
    }
    public int getBalance() {
        return Balance;
    }
    public void setBalance(int balance) {
        this.Balance = balance;
    }
 
    
    public void Print(){
        this.Point = Point + (int)(Pay*0.05);
        this.Balance = Balance + Pay;
        System.out.println("CardNumber:"+Cnumber);
        System.out.println("Onwer:"+Owner);
        System.out.println("결제금액:"+Pay);
        System.out.println("누적금액:"+Balance);
        System.out.println("포인트:"+Point);    
    }
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package Card;
 
public class CardCustom extends CreditCard{
    
    public static void main (String[] args){
        CreditCard M1= new CreditCard();
        
        M1.setCnumber("1111-5555-7778-9995");
        M1.setOwner("Taylor");
        M1.setPay(50000);
        M1.setBalance(M1.getBalance());
        M1.setPoint(M1.getPay());
        M1.Print();
        
    }    
 
}