From 4f8b6e0be5aea227d01472cebdc472e2d2089717 Mon Sep 17 00:00:00 2001 From: Yuan Yuan Date: Sat, 14 May 2022 18:01:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exercise_13.md | 23 ----------------------- exercise_14.md | 26 -------------------------- exercise_pre.md | 19 ------------------- 3 files changed, 68 deletions(-) delete mode 100644 exercise_13.md delete mode 100644 exercise_14.md delete mode 100644 exercise_pre.md diff --git a/exercise_13.md b/exercise_13.md deleted file mode 100644 index 6e9eee7..0000000 --- a/exercise_13.md +++ /dev/null @@ -1,23 +0,0 @@ -# 题目13 - -在有了三个Book的子类后,我们可以考虑创建这些类的对象了。 - -在创建对象时,可以直接创建,但一种更加优雅的方式是新建一个类,专门负责创建这些类的对象。 - -请创建一个BookSeller类。 - -## 答案 - -```java -public class BookSeller { - -} - -``` - -## 选项 - - - - - diff --git a/exercise_14.md b/exercise_14.md deleted file mode 100644 index d64f5d5..0000000 --- a/exercise_14.md +++ /dev/null @@ -1,26 +0,0 @@ -# 题目14 - -在BookSeller类中实现`public Book createBook(String name, String type);`方法,作用是当type等于"DB"时,创建一个DataBaseBook对象,对象的id是由IDHolder分配的id,name是参数的name,type是该类对应的枚举对象,pages为200,price为50.0。 - - -## 答案 - -```java - -public class BookSeller { - public Book createBook(String name, String type) { - if (type.equals("DB")) { - return new DataBaseBook(IDHolder.fetchId(), name, BookType.DataBaseBook, 200, 50.0); - } - return null; - } -} - -``` - -## 选项 - - - - - diff --git a/exercise_pre.md b/exercise_pre.md deleted file mode 100644 index 4db316d..0000000 --- a/exercise_pre.md +++ /dev/null @@ -1,19 +0,0 @@ -# OO技能树-1, 目标是了解创建对象的流程和工厂模式。 -# 题目 pre - -创建一个枚举类BookType,里面包含ObjectOrientedBook, DataBaseBook, OperatingSystemBook三个书的类型。 - - -## 答案 - -```java -public enum BookType { - ObjectOrientedBook, - DataBaseBook, - OperatingSystemBook -} - -``` - -## 选项 - -- GitLab