Results 1 to 5 of 5
- 07-21-2011, 12:23 AM #1
Member
- Join Date
- Jul 2011
- Location
- Universe
- Posts
- 5
- Rep Power
- 0
newbie: Getting started with java, need help on this
Hello,
so basically i am getting started with java.. I am doing work on eclipse, i am making a library project as a sample..
The library project includes the class of person and books..
here is my sample class of person:
I have done this, but now i need code by which a user will enter his maxBooks and Name, and also a code that will output name and maximum books of the person, it may be like this?Java Code:package Library; public class person { private String name; private int maxBooks; public person(){ name = "unknown name"; maxBooks = 0; } public String getName(){ return name; } public int getMaxBooks() { return maxBooks; } public void setMaxBooks(int maxBooks) { this.maxBooks = maxBooks; } public void setName(String name) { this.name = name; } }
?system.out.println(getPerson.name)
I have only taken two classes of java yet, sorry for this noob question.
Thanks for reading.
- 07-21-2011, 12:28 AM #2
You should abide by Java naming standards. Your class should be Person not person.
You need to write another test class. In the main method create a Person object and call some of the methods of the Person class. Add a bunch of print statements (should be System not system as per your example) to see what is happening. If you don't know about calling methods and passing parameters then read a tutuorial online (there should be plenty) or a book. Once you have done that, attempted to write some code and get stuck come back here and ask a specific question. "It doesn't work" is not specific nor a question.
- 07-21-2011, 01:39 AM #3
Member
- Join Date
- Jul 2011
- Location
- Universe
- Posts
- 5
- Rep Power
- 0
okay I follow the java naming convention as per your instructions, i have read some tutorials, and trying to call the Person.java in the Books.java.
Books.java records the book title, author and person(person.java needs to be called).
here is books.java
I am calling person.java, so need to add some code in it, i.e, when someone runs the books.java, it shows the name of the person who own it.Java Code:package Library; public class Books { private String title; private String author; private String person; public void books(){ title = "unknown title"; author = "unknown author"; person = "getPerson.name"; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public String getAuthor() { return author; } public void setAuthor(String author) { this.author = author; } }
- 07-21-2011, 01:46 AM #4
Why?
Pick up any book, look very carefully at it and ask yourself "Does the book know anything about me?", "Does the book need to know anything about me?".
What does need to know information about Book and Person is a Library. The Library will hold information about Books, Persons and what Books have been borrowed by which Persons.
- 07-21-2011, 01:51 AM #5
Member
- Join Date
- Jul 2011
- Location
- Universe
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
How to get started (Install Java and then Netbeans IDE)
By katon in forum New To JavaReplies: 2Last Post: 11-29-2009, 12:37 PM -
New to JAVA and need some help getting a started
By SMHouston in forum New To JavaReplies: 45Last Post: 09-05-2009, 09:55 AM -
How Does One Get Started Learning Java?
By Wataru in forum New To JavaReplies: 29Last Post: 08-08-2009, 10:45 AM -
Just started with Java
By javades in forum New To JavaReplies: 2Last Post: 07-24-2008, 06:39 AM -
Just getting started with java
By DuceDuceExplorer in forum IntroductionsReplies: 4Last Post: 06-29-2008, 06:13 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks