Results 21 to 36 of 36
- 05-31-2010, 09:55 AM #21
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
- 05-31-2010, 10:13 AM #22
Huh? You haven't created an Address class yet. And I don't see where you fill the List of addresses. You're like three steps further than you should be.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-31-2010, 10:21 AM #23
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
oh snap. i posted the wrong code and didnt recheck just now :P
the client class should be the same. at this linePHP Code:import java.io.*; import java.util.LinkedList; public class Address { LinkedList addressList = new LinkedList(); Address() { inputAdd(); } public void inputAdd() { try { BufferedReader br = new BufferedReader(new FileReader("Addresses.csv")); while(true) { String line = br.readLine(); if(line == null)break; addressList.add(line); System.out.println(line); // display the address } System.out.println(); br.close(); } catch(IOException io) { System.out.println(io.getMessage()); } } public Object getAddress(int index) { return addressList.get(index-1); // the list index starts with 0 } public static void main(String []args) { Address a=new Address(); System.out.println(a.getAddress(49)); //testing to get a specific address String s = (String)a.getAddress(0); String []sa = s.split(","); System.out.println(sa[3]+" - "+sa[2]); } }
System.out.println(sa[3]+" - "+sa[2]);
this is what i want to be displayed in the comboBox, and comboBox only takes 1 String [] as argument right ? So, there are 50 addresses ? what's the correct way ? :confused:
- 05-31-2010, 10:37 AM #24
Again, you should not add the line to the List, but 50 instances of a custom class Address. This class encapsulates the Client ID, road, post code etc, it does not do any file reading. You need to fill a CombBoxModel with those Address instances. And I'd use an ArrayList instead of a LinkedList.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-31-2010, 11:41 AM #25
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
i dont understand this part, so where do i actually do the file reading ?? im really confused now :confused:you should not add the line to the List, but 50 instances of a custom class Address.This class encapsulates the Client ID, road, post code etc, it does not do any file reading
- 05-31-2010, 11:55 AM #26
In some other class, or your main process class.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-31-2010, 11:57 AM #27
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
just to clarify, are u saying that the client & address classes are just to store data that is read from the static main method ?? then passing them around to other classes ?
- 05-31-2010, 12:04 PM #28
Yes, they are only used to store the data. No, your main method should never contain more than a handful lines of code.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-31-2010, 12:07 PM #29
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
oki doki, thanks a lot. let me try. 1st time learn object oriented :(
- 06-02-2010, 11:05 AM #30
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
Hi, I'm back :D
The attachment is my current project. Everything seems to work fine. Now I just need a way to export the data to a text file.
The format of output is
That's all :DL.K. Simons ABN 20-345-459 // my company name
Collection Service Invoice //title
Collection Date: 21-05-2010 //current date
Client: Megadodo Publications // owner of the address chosen from comboBox
Service Address:
12,Bowman St, Seven Hills, 2147 // comboBox
Collection Details:
Recycling : blah blah blah // anything from the NewCollection class
Net $xx,xx GST $xx,xx Total $xx,xx //also calculated in NewCollection class
- 06-02-2010, 11:12 AM #31
See reply #2, third link, IO tutorial. That covers all you need.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 06-02-2010, 11:40 AM #32
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
no no.. i know how to write to a file using BufferedWriter, but not in the format mentioned above, specifically with all the data. Do i have to make another class and then get information from 1 of the class I currently have or something ?
- 06-02-2010, 12:04 PM #33
Well you have all the information needed somewhere. Gather all the bits and pieces and pass them to an output class or method and write them to file.
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 06-02-2010, 12:18 PM #34
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
wa. informations are scattered all over the place. im doomed
- 06-02-2010, 04:16 PM #35
Senior Member
- Join Date
- Mar 2010
- Location
- Manila, Philippines
- Posts
- 257
- Rep Power
- 4
This thread is a String manipulation problem.
The solution are said to you.
Try reading the BufferedWriter API. This would solve on how you could manipulate the file. If I am not mistaken, using the append method would append a string to the file.
You should understand further how the data in the file are used and placed.
You're making progress in the last posts.Every project, package, class, method, variable, syntax, algorithm, etc.
are registered in my memory bank. Thanks to this thread.
- 06-02-2010, 04:50 PM #36
Member
- Join Date
- May 2010
- Posts
- 20
- Rep Power
- 0
Similar Threads
-
How to make a Jframe un-focusable when another Jframe is active?
By Robert_85 in forum Advanced JavaReplies: 4Last Post: 04-22-2009, 11:02 PM -
To get the current active window`s path using Windows API
By jihadrh in forum Advanced JavaReplies: 8Last Post: 12-01-2008, 02:07 PM -
Close Active Window (?)
By dcnorman07 in forum New To JavaReplies: 2Last Post: 10-03-2008, 05:55 PM -
Changing Active Window
By jmHoekst in forum New To JavaReplies: 1Last Post: 06-14-2008, 12:21 AM -
How to close an open JFrame window from a jsp page?
By kasisaiganesh in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-27-2008, 06:29 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks