I am developing a console application where I can register items. Each item has 3 properties serial number, model, year. I have 3 classes Laptop, Laptops(arraylist) and Office to run the application. So far I have managed to find the object itself by index number, but i need to list all objects with the property typed in.
This is how I ask user to choose the option
Laptops inHouse = new Laptops();
model = Console.askModel("Enter Model : ");
inHouse.findModel(model);
break;
That is the find method in Laptops class
public void findModel(String aModel)
{
int arraySize = laptops.size();
for(int i=0; i<arraySize; i++) {
if (laptops.get(i).getModel() == aModel) {
System.out.println(laptops.get(i));
}
}
}
this is the askModel method in Console class.
public static String askModel(String aModel)
{
System.out.println(aModel);
String model = askString("Enter the model: ");
return model;
}
Additionally, I am quite new to java, I understand the concept but still struggling on many thing so If I forgot to post a code which is needed to solve the problem I am sorry in advnace.