I created 2 source code files, Shirt.java and ShirtTestArray.java
The problem I am facing is that whenever I try to access the displayShirtInformation() method, I'm not able to do it.. and get an error class,interface,or enum expected
The 2 source files are given below--
Shirt.java--
public class Shirt {
public int shirtID = 0; // Default ID for the shirt
public String description = "-description required-"; // default
// The color codes are R=Red, B=Blue, G=Green, U=Unset
public char colorCode = 'U';
public double price = 0.0; // Default price for all shirts
public int quantityInStock = 0; // Default quantity for all shirts
public Shirt() {
}
public Shirt(int ID, String d, char c, double p, int q) {
shirtID = ID;
description = d;
colorCode = c;
price = p;
quantityInStock = q;
}
// This method displays the values for an item
public void displayShirtInformation() {
System.out.println("Shirt ID: " + shirtID);
System.out.println("Shirt description:" + description);
System.out.println("Color Code: " + colorCode);
System.out.println("Shirt price: " + price);
System.out.println("Quantity in stock: " + quantityInStock);
} // end of display method
} // end of class
ShirtTestArray.java --
public void ShirtTestArray{
public static void main(String [] args) {
Shirt [] shirtArray={new Shirt (1,"blue",'b',76.67,4),new Shirt(2,"green",'g',98.79,1),
new Shirt(3,"green",'g',34.78,90)};
shirtArray[0].displayShirtInformation();
shirtArray[1].displayShirtInformation();
shirtArray[2].displayShirtInformation();
}
}
immutableobject. You may also wish to change your 'color'charto anenum, to prevent data-entry errors (which your own code possibly falls victim to - is the case important?).