80 lines
1.7 KiB
Java
80 lines
1.7 KiB
Java
package model;
|
|
|
|
public class Image extends NewsItem {
|
|
private String author;
|
|
private int width;
|
|
private int height;
|
|
|
|
/**
|
|
* Creates an image with the given title and author and a resolution
|
|
* defined by width and height.
|
|
* @param title
|
|
* @param width
|
|
* @param height
|
|
* @param author
|
|
*/
|
|
public Image(String title, int width, int height, String author) {
|
|
this.title = title;
|
|
this.width = width;
|
|
this.height = height;
|
|
this.author = author;
|
|
}
|
|
|
|
/**
|
|
* Get the author of the image.
|
|
* @return author
|
|
*/
|
|
public String getAuthor() {
|
|
return author;
|
|
}
|
|
|
|
/**
|
|
* Get the width of the image.
|
|
* @return width
|
|
*/
|
|
public int getWidth() {
|
|
return width;
|
|
}
|
|
|
|
/**
|
|
* Get the height of the image.
|
|
* @return height
|
|
*/
|
|
public int getHeight() {
|
|
return height;
|
|
}
|
|
|
|
/**
|
|
* Renders the image as String and return the rendered image.
|
|
* @return String representing the rendered image
|
|
*/
|
|
public String renderToString() {
|
|
/*
|
|
* Dummy implementation
|
|
*/
|
|
return " /\\_/\\ \n( o.o )\n > ^ < ";
|
|
}
|
|
|
|
/**
|
|
* Print a list showing information about all directly or transitively
|
|
* referenced items in the given collection.
|
|
*/
|
|
@Override
|
|
public String getOverviewInformation() {
|
|
return "Image: " + this.getTitle()
|
|
+ ", Resolution: " + this.getWidth()
|
|
+ "x" + this.getHeight()
|
|
+ ", Author: " + this.getAuthor();
|
|
}
|
|
|
|
@Override
|
|
public String getDetailedInformation() {
|
|
StringBuilder builder = new StringBuilder();
|
|
builder.append("###" + this.getTitle() + "###");
|
|
builder.append("\n");
|
|
builder.append(renderToString());
|
|
builder.append("\n");
|
|
return builder.toString();
|
|
}
|
|
}
|