// 문제1 클래스 변경문제
/*
class CDInfo
{
 String registerNo;
 String title;
 CDInfo(String registerNo, String title)
 {
  this.registerNo = registerNo;
  this.title = title;
 }
}

class MusicCD extends CDInfo
{
 String artist;
 String music_name[];
 MusicCD(String registerNo, String title,
   String art, String musicname[])
 {
  // 슈퍼 클래스 생성자 사용
  super(registerNo, title);
  this.artist = art;
  this.music_name = musicname;
 }
 // 제대로 값이 들어갔는가 테스트용
 void Out()
 {
  System.out.println(this.registerNo);
  System.out.println(this.title);
  System.out.println(this.artist);
  System.out.println(this.music_name);
 }
}
public class main {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  MusicCD cd = new MusicCD("t-1","darkness","rosa","하늘을보면 하늘밖에");
  cd.Out();
 }
}
*/
/*
// 문제2번
class Rectangle
{
 private int width, height;
 Rectangle(int width, int height)
 {
  this.width = width;
  this.height = height;
 }
 
 int getWidth()
 {
  return this.width;
 }
 
 int getHeight()
 {
  return this.height;
 }
}

class Square extends Rectangle  // a부분
{
 Square(int sideLenght)
 {
  super(sideLenght, sideLenght);  // b부분
 }
 int getSideLength()
 {
  return this.getWidth();
 }
}

public class main {
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  Square rect = new Square(100);
  System.out.println(rect.getSideLength());
 }
}
*/
// 문제 3번
interface Lendable
{
 abstract void checkOut(String aborrower, String data);
 abstract void checkIn();
 abstract void Out_borrower();
 abstract void Out_checkoutdata();
}

class SeparateVolume implements Lendable
{
 String requsetNo;
 String bookTitle;
 String writer;
 String borrower;
 String checkOutData;
 byte state;
 SeparateVolume(String requsetNo, String bookTitle, String writer)
 {
  this.requsetNo = requsetNo;
  this.bookTitle = bookTitle;
  this.writer = writer;
 }
 public void checkOut(String borrower, String data)
 {
  if(state != 0)
   return;
 
  this.borrower = borrower;
  this.checkOutData = data;
  this.state = 1;
  System.out.println("*" + bookTitle + " 이(가) 대출되었다.");
  System.out.println("대출인" + borrower);
  System.out.println("대출일:" + data + "\n");
 }
 
 public void checkIn()
 {
  this.borrower = null;
  this.checkOutData = null;
  this.state = 0;
  System.out.println("*" + bookTitle + " 이(가) 반납됨\n");
 }
 public void Out_borrower()
 {
  System.out.println("대출인" + borrower);
 }
 public void Out_checkoutdata()
 {
  System.out.println("대출일:" + checkOutData + "\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 checkOutData;
 byte state;
 AppCDInfo(String registerNo, String title)
 {
  super(registerNo, title);
 }
 public void checkOut(String borrower, String data)
 {
  if(state != 0)
   return;
 
  this.borrower = borrower;
  this.checkOutData = data;
  this.state = 1;
  System.out.println("*" + title + "CD가 대출되었다.");
  System.out.println("대출인" + borrower);
  System.out.println("대출일:" + data + "\n");
 }
 
 public void checkIn()
 {
  this.borrower = null;
  this.checkOutData = null;
  this.state = 0;
  System.out.println("*" + title + "CD가 반납됨\n");
 }
 public void Out_borrower()
 {
  System.out.println("대출인" + borrower);
 }
 public void Out_checkoutdata()
 {
  System.out.println("대출일:" + checkOutData + "\n");
 }
}

public class main {
 public static void main(String[] args)
 {
  Lendable arr[] = {
    new AppCDInfo("2005-7001", "Redhat Fedora"),
    new SeparateVolume("859ㅂ986ㅊ","책상은 책상답게","빅셀")
  };
  checkOutAll(arr, "김수진", "20060318");
 }
 static void checkOutAll(Lendable arr[], String borrower, String data)
 {
  for(Lendable obj : arr)
  {
   obj.checkOut(borrower, data);
   obj.Out_borrower();
   obj.Out_checkoutdata();
  }
 }
}

interface MessageSender
//class MessageSender
{
/* String title;
 String senderName;
 
 // 인터페이스에선 추상 메소드만 선언해야 하는데, 생성자를 썻음
 MessageSender(String title, String sendName)
 {
  this.title = title;
  this.senderName = sendName;
 }
*/
 abstract void sendMessage(String recipient);
 
}

abstract class MessageSender
{
 String title;
 String senderName;
 
 // 인터페이스에선 추상 메소드만 선언해야 하는데, 생성자를 썻음
 MessageSender(String title, String sendName)
 {
  this.title = title;
  this.senderName = sendName;
 }
 abstract void sendMessage(String recipient);
}

+ Recent posts