Given that fact that your read loop works and is reading the file correctly, the only conclusion that could be draw is that Computer
is using static
fields to store the details you are assigning it.
This means that each instance of Computer
will have exactly the same information as each other.
For example, I imagine that you Computer
class looks something like...
public class Computer {
private static String manufacturer;
private static String model;
private static String memory;
private static String disk;
private static String cpu;
private static String optical;
private static String os;
private static String price;
public Computer(
String manufacturer,
String model,
String memory,
String disk,
String cpu,
String optical,
String os,
String price) {...
Remove the static
declearations on what should be instance fields, this way, each instance of Computer
will have unquie values for there properties...
Updated - static
method
Because the fields are no longer static
, you will either have to remove the static
modifier from the method, for example...
public void displayComputer() {
UIManager.put("OptionPane.messageFont", new FontUIResource(new Font("Courier New", Font.BOLD, 16)));
JOptionPane.showMessageDialog(null, "Inventory Computer Detail \n\n"
+ "Manufacturer: " + manufacturer
+ "\nModel Name: " + model
+ "\nMemory Size: " + memory
+ " GB \nDisk Size: " + disk
+ " GB \nCPU Type: " + cPU
+ "\nOptical Drive: " + optical
+ "\nOS Version: " + oS
+ "\nRetail Price: $" + String.format("%.2f", retailPrice),
"Geekazoid Inc.", JOptionPane.INFORMATION_MESSAGE);
}
And/or provide a Computer
reference as a parameter...
public static void displayComputer(Computer computer) {
UIManager.put("OptionPane.messageFont", new FontUIResource(new Font("Courier New", Font.BOLD, 16)));
JOptionPane.showMessageDialog(null, "Inventory Computer Detail \n\n"
+ "Manufacturer: " + computer.getManufacturer()
+ "\nModel Name: " + computer.getModel()
+ "\nMemory Size: " + computer.getMemory()
+ " GB \nDisk Size: " + computer.getDisk()
+ " GB \nCPU Type: " + computer.getCPU()
+ "\nOptical Drive: " + computer.getOptical()
+ "\nOS Version: " + computer.getOS()
+ "\nRetail Price: $" + String.format("%.2f", computer.getRetailPrice()),
"Geekazoid Inc.", JOptionPane.INFORMATION_MESSAGE);
}