gnu

블로그 이미지
by 군우

TAG CLOUD

  • Total hit
  • Today hit
  • Yesterday hit

//////// 메인 클래스 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
package project1105;
 
class testmain
{
    public static void main(String[] args)
    {
        System.out.println("이름, 폰번호, 생년월일 입력");
        PhoneInfo ph = new PhoneInfo("김근우","010-1234-5678","1999년생");
        ph.shows();
        System.out.println();
        PhoneInfo ph2 = new PhoneInfo("김근우","010-1234-5678");
        ph2.shows();
    }
}
cs



////////////phoneInfo 클래스 

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
/*
 * 단 생년월일 정보는 저장을 할수도 저장하지 않을수도 잇게끔 생성자를 정의하자.
 * 정의된 클래스의 확인을 위한 메인메소드 간단히정의하자
 */
 
package project1105;
 
public class PhoneInfo {
    String name;
    String phoneNumber;
    String birthday;
    public PhoneInfo(String name, String phoneNumber, String birthday   )
    {
        if (birthday=="0"){
            //System.out.println("생년월일을 모릅니다.");
            this.birthday = "모름";
            this.name = name;
            this.phoneNumber = phoneNumber;
        }
        else{
            this.name = name;
            this.phoneNumber = phoneNumber;
            this.birthday = birthday;
        }
        
        
    }
    public  PhoneInfo(String name, String phoneNumber)
    {
        //System.out.println("test NO NUM");
         this(name,phoneNumber,"0");
    }
    public void shows()
    {
        System.out.println("이름: "+ name+"\n"+"폰 번호: "+phoneNumber+
                "\n생년월일: "+birthday);
    }
}
cs


'Java > Java Training' 카테고리의 다른 글

13-1  (0) 2018.01.21
12-3  (0) 2018.01.20
11-1-2  (0) 2018.01.19
11-1-1  (0) 2018.01.19
9-2  (0) 2018.01.17
AND

ARTICLE CATEGORY

분류 전체보기 (197)
C (0)
HTML (7)
C# (88)
Python (27)
IT (0)
Android (2)
Java (65)
Study (5)
JavaScript (1)
JSP (2)

RECENT ARTICLE

RECENT COMMENT

CALENDAR

«   2025/04   »
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

ARCHIVE

LINK