Results 1 to 6 of 6
Thread: Implementation problem
- 03-08-2012, 10:39 PM #1
Member
- Join Date
- Mar 2012
- Location
- Vestal, NY
- Posts
- 36
- Rep Power
- 0
Implementation problem
Hello again, sorry to post again so soon
I'm developing a class hierarchy of books, and my implementation skills are not quite adequate.
take a look
it says that novel doesn't overwrite the abstract classes in book, am i overlooking something?Java Code://Book interface public interface Book { public int numPages(); public String bookTitle(); public String authorName(); public boolean isHardCover(); public boolean isOpen(); public void open(); public void close(); } //novel class public class Novel implements Book { private int pages; private String title; private String authorfirst; private String authorlast; private boolean hardCover; private boolean Open; public Novel(String booktitle, int numpages, String lastname, String firstname, boolean _hardCover) { pages = numpages; title = booktitle; authorlast = lastname; authorfirst = firstname; hardCover = _hardCover; Open = false; } public int numPages() { return pages; } public String bookTitle() { return title; } public String authorName() { return authorlast + ", " + authorfirst; } public boolean isHardCover() { return hardCover; } public void isOpen() { return Open; } public void open() { isOpen = true; } public void close() { isOpen = false; } }
- 03-08-2012, 10:44 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Implementation problem
there is no variable isOpen! (do you mean Open? :D) and if a method is declared as void, you can`t return something :DJava Code:public void isOpen() { return Open; } public void open() { isOpen = true; } public void close() { isOpen = false; }
- 03-08-2012, 10:48 PM #3
Member
- Join Date
- Mar 2012
- Location
- Vestal, NY
- Posts
- 36
- Rep Power
- 0
Re: Implementation problem
wow. i need to drink some coffee can't believe i missed that. The variable Open was isOpen and i missed those. Also the declaration is just plain dumb on my part. thank you very much!
- 03-09-2012, 09:35 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Implementation problem
Just a note, but there's no need at all (and it's generally frowned upon) to declare the methods in an interface as 'public'.
They're all public by default.Please do not ask for code as refusal often offends.
- 03-09-2012, 09:25 PM #5
Member
- Join Date
- Mar 2012
- Location
- Vestal, NY
- Posts
- 36
- Rep Power
- 0
Re: Implementation problem
Oh i know tolls, its just that this is a class and she takes off if we don't use the public. The programs i do outside of homework i dont use the public keyword
- 03-11-2012, 03:57 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Problem with the result of the implementation
By ŖàΫ ỏƒ Ңόρę in forum New To JavaReplies: 5Last Post: 01-11-2010, 05:33 AM -
Queue implementation - Enqueue problem
By jefrazie in forum New To JavaReplies: 5Last Post: 11-05-2009, 01:10 AM -
Problem in Calculator implementation using Stack
By realahmed8 in forum New To JavaReplies: 1Last Post: 12-19-2008, 11:58 PM -
Problem in file implementation
By BHCluster in forum New To JavaReplies: 6Last Post: 04-21-2008, 03:21 AM -
Implementation of the Producer/Consumer problem in Java
By Java Tip in forum java.langReplies: 0Last Post: 04-09-2008, 06:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks