Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #16  
Old February 6th, 2012, 05:59 PM
Cameron0960 Cameron0960 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 36 Cameron0960 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 30 m 26 sec
Reputation Power: 1
One thing that has always helped me when writing larger programs is to test certain aspects of my program as they are written. For example, if I were writing your Book program, I would write a class for file input. Then I would test it and ensure that it was performing the input properly.

So, my advice is to ensure that one part of your program is working, then move onto the next. If you are having issues getting a specific piece working, then put it up here with input and output and describe the problem.
Comments on this post
NormR agrees!

Reply With Quote
  #17  
Old February 7th, 2012, 01:15 PM
qwerty101 qwerty101 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 30 qwerty101 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 5 m 54 sec
Reputation Power: 1
Quote:
Originally Posted by Cameron0960
One thing that has always helped me when writing larger programs is to test certain aspects of my program as they are written. For example, if I were writing your Book program, I would write a class for file input. Then I would test it and ensure that it was performing the input properly.

So, my advice is to ensure that one part of your program is working, then move onto the next. If you are having issues getting a specific piece working, then put it up here with input and output and describe the problem.


Thanks for your response, i totally agree.
My program is running fine up to this point, works great, and reads in values/user input as it should.

Unfortunately i don't know how to make the program print out the data that has been input.
ie. After inputing 3 Books worth of data, i want the program to then print the smallLib, in turn, printing out the books details that were intially put in.

I have ok knowledge with smaller programs, arraylists, switches, loops, printlns etc. But for some reason, i have no idea how to take this further java wise.
In my head i know exactly what i want ha, its just writing it...
Thanks again anyway.

Reply With Quote
  #18  
Old February 7th, 2012, 01:36 PM
NormR's Avatar
NormR NormR is offline
Contributing User
Click here for more information.
 
Join Date: Aug 2010
Location: Eastern Florida
Posts: 1,758 NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level)NormR User rank is Captain (20000 - 30000 Reputation Level) 
Time spent in forums: 1 Week 20 h 51 sec
Reputation Power: 288
Where is the data your want to print?
How can you get to that data?
How do you want to format the data when you print it?

Reply With Quote
  #19  
Old February 7th, 2012, 01:59 PM
Cameron0960 Cameron0960 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 36 Cameron0960 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 30 m 26 sec
Reputation Power: 1
Quote:
Originally Posted by qwerty101
Thanks for your response, i totally agree.
My program is running fine up to this point, works great, and reads in values/user input as it should.

Unfortunately i don't know how to make the program print out the data that has been input.
ie. After inputing 3 Books worth of data, i want the program to then print the smallLib, in turn, printing out the books details that were intially put in.

I have ok knowledge with smaller programs, arraylists, switches, loops, printlns etc. But for some reason, i have no idea how to take this further java wise.
In my head i know exactly what i want ha, its just writing it...
Thanks again anyway.


What I normally do for output is write a method for each of my classes that look like the following:

Code:
Class Book {
private String title;

public Book (String title) {
this.title = title;
}

public String toString() {

String output = "";

output += "Title: " + title;
return output;

} // closes toString() method


After writing such a method, I am able to simply add the following code to my main to print the contents of that object:
Code:
public static void main(String[] args) {
Book book1 = new Book("Oliver Twist");
System.out.println(book1); // this will call the toString() method of the book class


So, the output of this would be "Oliver Twist".

In your example, you are storing Book objects in an ArrayList. So, what I would recommend is writing a toString() method in the class you've written that contains the arrayList data structure. Have that method go through each index of your arrayList, get the Book object at position index, concatenate all the output into a single String and return it.

Then, you will be able to simply say in your main:
Code:
public static void main() {
BookList books = new BookList();
System.out.println(books);


This will then output all the books that are stored in the books instance of BookList.

Hope that helps, I can show you an example of printing the entire contents of an arrayList using the method I mentioned above if it would help further. Although, if I did that, I would basically be handing you code lol..

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Adding Books to a Library Object


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 10 - Follow our Sitemap