SS 2025
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
public class Printmedia implements Readable {
|
||||
|
||||
private int currentPage;
|
||||
protected int maxPage;
|
||||
|
||||
public Printmedia(int currentPage, int maxPage) {
|
||||
this.currentPage = currentPage;
|
||||
this.maxPage = maxPage;
|
||||
}
|
||||
|
||||
public int getCurrentPage() {
|
||||
return currentPage;
|
||||
}
|
||||
|
||||
public int getMaxPage() {
|
||||
return maxPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(int amount) {
|
||||
if (currentPage + amount > maxPage) {
|
||||
throw new RuntimeException(
|
||||
"Cannot read because currentPage would exceed maxPage");
|
||||
}
|
||||
currentPage += amount;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user