S003_ContactsClass2 여러 Class 사용
2019. 5. 14. 11:31
Programing/Java
package kr.ac.jj.java201562054; import java.util.Scanner; public class S003_ContactsClass2 { public static void main(String[] args) { // TODO Auto-generated method stub Friend f = new Friend(); f.Input(); f.Print(); Book b = new Book(); b.BInput(); b.BPrint(); } } class Book { String title, author, publisher;// 제목 저자 출판사 int price; // 가격 Scanner scan = new Scanner(System.in); public void BInput() { System.out.printf("제목:"); this.title = scan.next(); System.out.printf("저자:"); this.author = scan.next(); System.out.printf("출판사:"); this.publisher = scan.next(); System.out.printf("가격:"); this.price = scan.nextInt(); } public void BPrint() { System.out.print("제목:" + this.title + "\n저자:" + author + "\n출판사:" + publisher + "\n가격:" + price); } } class Friend { String name; String phone; int speed_dial; public void Input() { Scanner scan = new Scanner(System.in); System.out.print("\n이름: "); this.name = scan.next(); System.out.print("휴대폰: "); this.phone = scan.next(); System.out.print("단축번호: "); this.speed_dial = scan.nextInt(); } public void Print() { System.out.println("\n이름 : " + this.name + "\n휴대폰 : " + this.phone + "\n단축번호 : " + this.speed_dial); } }
'Programing > Java' 카테고리의 다른 글
S007_Sungjuk_UnivStudent 대학성적 계산예제 (0) | 2019.05.14 |
---|---|
S007_Sungjuk 성적계산 및 입출력 (0) | 2019.05.14 |
S003_ContactsClass1 클래스 사용 (0) | 2019.05.14 |
S003_Contacts (0) | 2019.05.14 |
T002_SmartPhoneContact 전화번호부 간단 입출력 (0) | 2019.05.14 |