java - Error: Book is not abstract and does not override abstract method getPageCount in Citable. Should I make a class abstract due to interface class? -


i'm trying school project in i'm writing application deals books, collections of books (we’ll call library), , ui client classes.

one of classes class called citable requires implementation of typical accessor features return book’s isbn, author, title, , publisher (all strings) publication year, month, , day (all integers) , page count (an integer).

the next class book class implements citable interface. library need sort books isbn numbers, in book you’ll need provide support (hint: requires implementation of additional interface (one don’t have write, implement) , writing of additional method (which should need 1 line of code), , library make simple call make sort happen). there no statics here (except test method), , no ui whatsoever. i'll show i've did far:

public interface citable {     public string getisbn();     public string getauthor();     public string gettitle();     public string getpublisher();     public int getpublicationyear();     public int getmonth();     public int getday();     public int getpagecount(); } 

and book interface:

import java.util.*; public abstract class book implements citable, comparable {     /**      * constructor objects of class book      */     public book()     {         collections.sort(isbn);     }      public string tostring (){         string info =  isbn + "\n" + title + "\n" + author + "\n" + publisher +          "\n" + publicationyear + "\n" + month + "\n" + day;         return info;     } } 

in book class, i'm implementing both interface i've made , java's built-in comparable. question this: in book class, getting error: book not abstract , not override abstract method getpagecount in citable. way stop error make book class abstract. however, i'm getting no indication should make class abstract. there way out of this?

your class book implements 2 interfaces, namely citable , comparable. means have implement methods these interfaces in class. other way make class book abstract, meaning can't instantiate it. not want.

your class book this:

public class book implements citable, comparable {     /**      * constructor objects of class book      */     public book()     {         collections.sort(isbn);     }      public string tostring (){         string info =  isbn + "\n" + title + "\n" + author + "\n" + publisher +          "\n" + publicationyear + "\n" + month + "\n" + day;         return info;     }      @override     public int compareto(object o) {         //implement method     }      @override     public string getisbn() {         return isbn;     }      //other methods interfaces here... } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -