0

Hi,

this is my first post here, and I really need some help with my homework. I'm a newbie to Java programming, and I have this assignment:

Write an application which reads data from a file about certain items (one row - one item, stored are the integer valued code, amount and name of an item) into one of Java's collections (e.g. Vector, ArrayList or LinkedList). After that, user, from standard input, enters item's code (e.g. 253201) and amount he wants, and program updates the amount of that item in collection, and it displays the message to the user with the name of the item he bought. After the end of the program, the updated state is written in the same text file over the old state (the data are overwritten). GUI realization is not needed.

That's what I should do. So practically, the program needs to read from file (data about items, 1 per line which contains 3 data: code, amount and name), puts the read data into a Java collection, user enters the code and amount for one of the items, the data are updated and written over the existing data in the existing file. The user is previously shown what he entered.

How do I do this? Thanks for help! If you need my mail for something, it's boris90@gmail.com.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by DavidKroukamp
0

Hi,

this is my first post here, and I really need some help with my homework. I'm a newbie to Java programming, and I have this assignment:

Write an application which reads data from a file about certain items (one row - one item, stored are the integer valued code, amount and name of an item) into one of Java's collections (e.g. Vector, ArrayList or LinkedList). After that, user, from standard input, enters item's code (e.g. 253201) and amount he wants, and program updates the amount of that item in collection, and it displays the message to the user with the name of the item he bought. After the end of the program, the updated state is written in the same text file over the old state (the data are overwritten). GUI realization is not needed.

The best way to get started is to break down your code:
1)read the file- so find out how to read text from a file in java
2)put all the data the file reads into 3 array lists or 1 but thats confusing-find out how to populate array list(s)
3)next bring up a input dialog- this is known as showInputDialog() research how to do that-find out how to show an JOptionpane inputdialog and get the results
4)Search the first array for the item matching what the user entered-find out how to search an array list
5)Get the rest of the arrays to the same index as that found by the above method
6)Edit the necessary array entry(s)-find out how to edit/add/remove values from array list
6) write information back to a text file-find out hoe to write text to file in java

Try thise steps and come back with some code to show and questions to be answered and more help will be given :)

Edited by DavidKroukamp: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.