diff --git a/ueb05_news_example/src/model/Article.java b/ueb05_news_example/src/model/Article.java index bb0b8fc2..24977e7b 100644 --- a/ueb05_news_example/src/model/Article.java +++ b/ueb05_news_example/src/model/Article.java @@ -1,10 +1,6 @@ package model; -public class Article extends Item { - private String title; - private String author; - private String content; - +public class Article extends AuthoredItem { // Fill in dummy content { content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, " @@ -34,30 +30,4 @@ public class Article extends Item { + getContent() + "\n\n"; } - - //================================= - - /** - * Get the title of the article. - * @return title - */ - public String getTitle() { - return title; - } - - /** - * Get the author of the article. - * @return author - */ - public String getAuthor() { - return author; - } - - /** - * Get the content of the article. - * @return - */ - public String getContent() { - return content; - } } diff --git a/ueb05_news_example/src/model/AuthoredItem.java b/ueb05_news_example/src/model/AuthoredItem.java new file mode 100644 index 00000000..d3deb088 --- /dev/null +++ b/ueb05_news_example/src/model/AuthoredItem.java @@ -0,0 +1,33 @@ +package model; + +public abstract class AuthoredItem extends Item{ + protected String title; + protected String author; + protected String content; + + /** + * Get the title of the AuthoredItem. + * + * @return title + */ + public String getTitle() { + return title; + } + + /** + * Get the author of the AuthoredItem. + * + * @return author + */ + public String getAuthor() { + return author; + } + + /** + * Get the content of the AuthoredItem. + * @return content + */ + public String getContent() { + return content; + } +} diff --git a/ueb05_news_example/src/model/Image.java b/ueb05_news_example/src/model/Image.java index 6c3b671f..060c0ff3 100644 --- a/ueb05_news_example/src/model/Image.java +++ b/ueb05_news_example/src/model/Image.java @@ -1,11 +1,14 @@ package model; -public class Image extends Item { - private String title; - private String author; +public class Image extends AuthoredItem { private int width; private int height; + // Fill in dummy content + { + content = " /\\_/\\ \n( o.o )\n > ^ < "; + } + /** * Creates an image with the given title and author and a resolution * defined by width and height. @@ -38,24 +41,6 @@ public class Image extends Item { //================================= - /** - * Get the title of the image. - * - * @return title - */ - public String getTitle() { - return title; - } - - /** - * Get the author of the image. - * - * @return author - */ - public String getAuthor() { - return author; - } - /** * Get the width of the image. * @@ -73,16 +58,4 @@ public class Image extends Item { public int getHeight() { return height; } - - /** - * Renders the image as String and return the rendered image. - * - * @return String representing the rendered image - */ - public String getContent() { - /* - * Dummy implementation - */ - return " /\\_/\\ \n( o.o )\n > ^ < "; - } }