Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Book {
- String title;
- String author;
- int pages;
- int currentPage;
- void printInfo() {
- System.out.println("Book title is " + this.title);
- System.out.println("The author is " + this.author);
- System.out.println("Number of pages is " + this.pages);
- System.out.println("The current page is " + this.currentPage);
- }
- void skipPages(int plusPages) throws Exception {
- if(this.currentPage + plusPages > this.pages) {
- throw new Exception();
- } else {
- this.currentPage += plusPages;
- }
- }
- void nextPage() throws Exception {
- if(this.currentPage + 1 > this.pages) {
- throw new Exception();
- } else {
- this.currentPage += 1;
- }
- }
- }
Add Comment
Please, Sign In to add comment