1b: combine fields title and topic
This commit is contained in:
parent
3f30173a5b
commit
cfeaba3cab
@ -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.
|
||||
*
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,10 @@ import java.util.List;
|
||||
|
||||
public class NewsCollection extends Item {
|
||||
|
||||
private String topic;
|
||||
private List<Item> 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user