| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- currentTimeMillis
- 프리티어
- code 설치
- '티스토리 초대장/ 티스토리초대'
- 초대장
- 프레시업 #풀무원 #하루한병 #건강만들기 #풀무원 녹즙
- React Native
- 니돈내먹
- gitlab 연동
- 티스토리초대
- GitLab Mirroring
- GitHub 미러링
- 티스토리 초대장/ 티스토리초대
- 음료같은녹즙
- visual studio code cli
- 실행시간 측정
- react native #gradle
- 티스토리 초대장
- webstorm
- 네이버 클라우드 플랫폼
- visual studio code
- eslint-import-resolver-typescript
- Emmet
- 유니옥션
- code 세팅
- settings sync
- GitHub Mirroring
- GitLab미러링
- Path Alias
- code .
Archives
- Today
- Total
방치하기
홍대 자바 수업 .도서관 객체 . 인터페이스 와 상속 본문
반응형
interface Lendable {
abstract void checkOut(String borrower, String date);
abstract void checkIn();
}
class SeparateVolume implements Lendable {
String requestNo; // 청구번호
String bookTitle; // 제목
String writer; // 저자
String borrower; // 대출인
String checkOutDate; // 대출일
byte state; // 대출상태
SeparateVolume(String requestNo, String bookTitle,
String writer) {
this.requestNo = requestNo;
this.bookTitle = bookTitle;
this.writer = writer;
}
public void checkOut(String borrower, String date) { // 대출한다
if (state != 0)
return;
this.borrower = borrower;
this.checkOutDate = date;
this.state = 1;
System.out.println("*" + bookTitle + " 이(가) 대출되었습니다.");
System.out.println("대출인:" + borrower);
System.out.println("대출일:" + date + "\n");
}
public void checkIn() { // 반납한다
this.borrower = null;
this.checkOutDate = null;
this.state = 0;
System.out.println("*" + bookTitle + " 이(가) 반납되었습니다.\n");
}
}
class CDInfo {
String registerNo; // 관련번호
String title; // 타이틀
CDInfo(String registerNo, String title) {
this.registerNo = registerNo;
this.title = title;
}
}
class AppCDInfo extends CDInfo implements Lendable {
String borrower; // 대출인
String checkOutDate; // 대출일
byte state; // 대출상태
AppCDInfo(String registerNo, String title) {
super(registerNo, title);
}
public void checkOut(String borrower, String date) { // 대출한다
if (state != 0)
return;
this.borrower = borrower;
this.checkOutDate = date;
this.state = 1;
System.out.println("*" + title + " CD가 대출되었습니다.");
System.out.println("대출인:" + borrower);
System.out.println("대출일:" + date + "\n");
}
public void checkIn() { // 반납한다
this.borrower = null;
this.checkOutDate = null;
this.state = 0;
System.out.println("*" + title + " CD가 반납되었습니다.\n");
}
}
class Dictionary {
String title;
String registerNo;
Dictionary(String registerNo,String title) {
this.title = title;
this.registerNo = registerNo;
}
}
class AppDic extends Dictionary implements Lendable
{
String borrower; // 대출인
String checkOutDate; // 대출일
String chul;
byte state; // 대출상태
AppDic(String registerNo, String title,String chul) {
super(registerNo, title);
this.chul=chul;
}
public void checkOut(String borrower, String date) { // 대출한다
if (state == 1)
return;
this.borrower = borrower;
this.checkOutDate = date;
this.state = 1;
System.out.println("*" + title+" 출판사:"+chul + " 사전이 대출되었습니다.");
System.out.println("대출인:" + borrower);
System.out.println("대출일:" + date + "\n");
}
public void checkIn() { // 반납한다
this.borrower = null;
this.checkOutDate = null;
this.state = 0;
System.out.println("*" + title + " 사전이 반납되었습니다.\n");
}
}
class InterfaceExample1 {
public static void main(String args[]) {
SeparateVolume obj1 = new SeparateVolume("863ㅂ774개", "개미",
"베르베르");
AppCDInfo obj2 = new AppCDInfo("2005-7001", "Redhat Fedora");
AppDic obj3= new AppDic("2005-7001", "영한사전", "동아");
obj1.checkOut("김영숙", "20060315");
obj2.checkOut("박희경", "20060317");
obj3.checkOut("이준호", "20060315");
obj1.checkIn();
obj2.checkIn();
}
}
반응형
'홍익대 Java > 수업' 카테고리의 다른 글
| 홍대 자바 수업 ,Wrapper 클래스 기본형 대신 레퍼런스 형 +오토 (언)박싱 +2,8,16진수 변환 (0) | 2009.07.27 |
|---|---|
| 홍대 자바 수업 : 객체의 수를 제한하는 방법론적. (0) | 2009.07.24 |
| 홍대 수업 자바 한글 스트링 인식해서 갯수 세주기 str.getBytes().length; (0) | 2009.07.24 |
| 홍대 자바 수업 : 강제적 업캐스팅 (0) | 2009.07.23 |
| 홍대 자바 수업 : 상속 관계인지 확인 instanceof (0) | 2009.07.23 |
Comments