diff --git a/ueb05_news_example/src/model/AuthoredItem.java b/ueb05_news_example/src/model/AuthoredItem.java index 50b07bf1..2ab22537 100644 --- a/ueb05_news_example/src/model/AuthoredItem.java +++ b/ueb05_news_example/src/model/AuthoredItem.java @@ -1,7 +1,6 @@ package model; public abstract class AuthoredItem extends Item{ - protected String title; protected String author; protected String content; @@ -12,17 +11,6 @@ public abstract class AuthoredItem extends Item{ + "\n\n"; } - //================================= - - /** - * Get the title of the AuthoredItem. - * - * @return title - */ - public String getTitle() { - return title; - } - /** * Get the author of the AuthoredItem. * diff --git a/ueb05_news_example/src/model/Item.java b/ueb05_news_example/src/model/Item.java index e4f63f48..97c32ccd 100644 --- a/ueb05_news_example/src/model/Item.java +++ b/ueb05_news_example/src/model/Item.java @@ -1,6 +1,17 @@ package model; public abstract class Item { + protected String title; + public abstract String getOverview(); public abstract String getDetails(); + + /** + * Get the title of the item. + * + * @return title + */ + public String getTitle() { + return title; + } } diff --git a/ueb05_news_example/src/model/NewsCollection.java b/ueb05_news_example/src/model/NewsCollection.java index 7d989220..719d918f 100644 --- a/ueb05_news_example/src/model/NewsCollection.java +++ b/ueb05_news_example/src/model/NewsCollection.java @@ -5,11 +5,10 @@ import java.util.List; public class NewsCollection extends Item { - private String topic; private List items = new LinkedList<>(); - public NewsCollection(String topic) { - this.topic = topic; + public NewsCollection(String title) { + this.title = title; } /** @@ -18,7 +17,7 @@ public class NewsCollection extends Item { */ public String getOverview(){ StringBuilder builder = new StringBuilder(); - builder.append("###" + getTopic() + "###"); + builder.append("###" + getTitle() + "###"); builder.append("\n"); for(Item item : getItems()){ builder.append(item.getOverview()); @@ -33,7 +32,7 @@ public class NewsCollection extends Item { */ public String getDetails(){ StringBuilder builder = new StringBuilder(); - builder.append("###" + getTopic() + "###"); + builder.append("###" + getTitle() + "###"); builder.append("\n"); for (Item item : getItems()) { builder.append(item.getDetails()); @@ -43,13 +42,6 @@ public class NewsCollection extends Item { //================================= - /** - * Get the topic of the collection. - * @return - */ - public String getTopic() { - return topic; - } /** * Get the list of items stored directly in this collection. * @return items stored in this collection