1b: add AuthoredItem as superclass for Article and Image
This commit is contained in:
parent
261f9bb800
commit
db12a40520
@ -1,10 +1,6 @@
|
|||||||
package model;
|
package model;
|
||||||
|
|
||||||
public class Article extends Item {
|
public class Article extends AuthoredItem {
|
||||||
private String title;
|
|
||||||
private String author;
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
// Fill in dummy content
|
// Fill in dummy content
|
||||||
{
|
{
|
||||||
content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
|
content = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
|
||||||
@ -34,30 +30,4 @@ public class Article extends Item {
|
|||||||
+ getContent()
|
+ getContent()
|
||||||
+ "\n\n";
|
+ "\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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
33
ueb05_news_example/src/model/AuthoredItem.java
Normal file
33
ueb05_news_example/src/model/AuthoredItem.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,14 @@
|
|||||||
package model;
|
package model;
|
||||||
|
|
||||||
public class Image extends Item {
|
public class Image extends AuthoredItem {
|
||||||
private String title;
|
|
||||||
private String author;
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
|
// Fill in dummy content
|
||||||
|
{
|
||||||
|
content = " /\\_/\\ \n( o.o )\n > ^ < ";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an image with the given title and author and a resolution
|
* Creates an image with the given title and author and a resolution
|
||||||
* defined by width and height.
|
* 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.
|
* Get the width of the image.
|
||||||
*
|
*
|
||||||
@ -73,16 +58,4 @@ public class Image extends Item {
|
|||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return height;
|
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 > ^ < ";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user