From b10932e58780bbe43ad1817bb70497ce4aba857a Mon Sep 17 00:00:00 2001 From: arinming Date: Wed, 17 Jan 2024 01:19:31 +0900 Subject: [PATCH] =?UTF-8?q?[Week2][Chap9]=20=EB=AC=B8=EC=A0=9C=EC=99=80=20?= =?UTF-8?q?=ED=92=80=EC=9D=B4=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java-basic/src/extends1/ex/Album.java" | 19 +++++++++++++++++ .../java-basic/src/extends1/ex/Book.java" | 21 +++++++++++++++++++ .../java-basic/src/extends1/ex/Item.java" | 19 +++++++++++++++++ .../java-basic/src/extends1/ex/Movie.java" | 21 +++++++++++++++++++ .../java-basic/src/extends1/ex/ShopMain.java" | 18 ++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 "\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Album.java" create mode 100644 "\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Book.java" create mode 100644 "\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Item.java" create mode 100644 "\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Movie.java" create mode 100644 "\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/ShopMain.java" diff --git "a/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Album.java" "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Album.java" new file mode 100644 index 0000000..ea7459f --- /dev/null +++ "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Album.java" @@ -0,0 +1,19 @@ +package extends1.ex; + +public class Album extends Item { + + private String artist; + + public Album(String name, int price, String artist) { + super(name, price); + this.artist = artist; + } + + @Override + public void print() { + super.print(); + System.out.println("- 아티스트: " + artist); + } + + +} diff --git "a/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Book.java" "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Book.java" new file mode 100644 index 0000000..dac86cb --- /dev/null +++ "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Book.java" @@ -0,0 +1,21 @@ +package extends1.ex; + +public class Book extends Item { + + private String author; + private String isbn; + + public Book(String name, int price, String author, String isbn) { + super(name, price); + this.author = author; + this.isbn = isbn; + } + + @Override + public void print() { + super.print(); + System.out.println("- 저자: " + author + ", isbn: " + isbn); + } + + +} diff --git "a/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Item.java" "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Item.java" new file mode 100644 index 0000000..982701a --- /dev/null +++ "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Item.java" @@ -0,0 +1,19 @@ +package extends1.ex; + +public class Item { + private String name; + private int price; + + public Item(String name, int price) { + this.name = name; + this.price = price; + } + + public void print() { + System.out.println("이름: " + name + ", 가격: " + price); + } + + public int getPrice() { + return price; + } +} diff --git "a/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Movie.java" "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Movie.java" new file mode 100644 index 0000000..c586dda --- /dev/null +++ "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/Movie.java" @@ -0,0 +1,21 @@ +package extends1.ex; + +public class Movie extends Item { + + private String director; + private String actor; + + public Movie(String name, int price, String director, String actor) { + super(name, price); + this.director = director; + this.actor = actor; + } + + @Override + public void print() { + super.print(); + System.out.println("- 감독: " + director + ", 배우: " + actor); + } + + +} diff --git "a/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/ShopMain.java" "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/ShopMain.java" new file mode 100644 index 0000000..bedac7e --- /dev/null +++ "b/\352\271\200\354\225\204\353\246\260/java-basic/src/extends1/ex/ShopMain.java" @@ -0,0 +1,18 @@ +package extends1.ex; + +public class ShopMain { + public static void main(String[] args) { + + Book book = new Book("JAVA", 10000, "han", "12345"); + Album album = new Album("앨범1", 15000, "seo"); + Movie movie = new Movie("영화1", 18000, "감독1", "배우1"); + + book.print(); + album.print(); + movie.print(); + + int sum = book.getPrice() + album.getPrice() + movie.getPrice(); + System.out.println("상품 가격의 합: " + sum); + + } +}