본문 바로가기
Language/Java 예제

[Java예제] 책 목록 및 가격계산 예제

by 나비와꽃기린 2015. 1. 30.


class Book 
{
 private String title;
 private int price;
 
 Book(){};
 
 Book(String title,int price){
  this.title=title;
  this.price=price;
 }
 
 
 public void setTitle(String title){
  this.title=title;
 }
 
 public String getTitle(){
  return title;
 }
 
 public void setPrice(int price){
  this.price=price;
 }
 
 public int getPrice(){
  return price;
 }
}
 
 
class BookMgr extends Book{
 
 Book[] bookList=new Book[5];
 
 BookMgr(){};
 
 BookMgr(Book[] bookList){
  this.bookList=bookList;
 }
 
 public void printBookList(){
  for(int i=0;i

댓글0