IDifferent data type arrays to .dat file?
Another newbie needing help. I know how to iterate some integer values and write them to a .dat file, using FileWriter, BufferedWriter and PrintWriter (java.io.*)....
Now i'm wanting to advance to this: I want to prompt the user for data input of three different types - integer, String and float, and so populate a .dat file, allowing for say, 100 array records.
e.g each record to have something like,
<Code>:<Description>:<Qty>:<Price>
A24 Mars Bar 6 1.40
Just need some help to start creating the mixed-type arrays. Hope you can gather what i'm wanting.Thanks.
[630 byte] By [
DuffyDuma] at [2007-10-2 6:10:17]

Hi DuffyDum,
I do not understand the question all that well. But I think you want to store information about products or something else in an array.
Here is my suggestion.
First create a class to store data about each product.
ex:
public class Product
{
private int Code ;
private String Description = "";
private int Quantity ;
private float Price ;
public void setCode(int code)
{
Code = code;
}
public int getCode()
{
return Code;
}
//Write get and set methods for each attribute of product
}
Now in you main program.
//Create a Product type array
Product products[] = new Product[100];
//Create Product type objects for each product user enters and store them in the array.
Product my_product_object = new Product();
my_product_object.setCode(5);// 5 is just a value. It can be anything user
// enters
//Set other values as well.
my_product_object[0] = my_product_object; //Put product object to arrays
//first element
Hope this helps,
Chamal.