Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.ArrayList; import java.util.List; class Guitar { String color; String brand; String model; double price; boolean isSecondHand; String warehouse; int stockNumber; public Guitar ( String
import java.util.ArrayList;
import java.util.List;
class Guitar
String color;
String brand;
String model;
double price;
boolean isSecondHand;
String warehouse;
int stockNumber;
public GuitarString color, String brand, String model, double price, boolean isSecondHand, String warehouse, int stockNumber
this.color color;
this.brand brand;
this.model model;
this.price price;
this.isSecondHand isSecondHand;
this.warehouse warehouse;
this.stockNumber stockNumber;
class Inventory
List guitars new ArrayList;
public void addGuitarGuitar guitar
for Guitar existingGuitar : guitars
if existingGuitarbrand.equalsguitarbrand && existingGuitar.model.equalsguitarmodel
existingGuitar.stockNumber;
return;
guitars.addguitar;
public Guitar searchGuitarString brand, String model, double price
for Guitar guitarItem : guitars
if guitarItembrand brand && guitarItem.model model && guitarItem.price price
return guitarItem;
return null;
public class Main
public static void mainString args
Inventory inventoryList new Inventory;
Guitar guitar new GuitarPurple "Fender", AH false, "Warehouse;
inventoryList.addGuitarguitar;
Guitar guitar new GuitarYellow "Yamaha", BT true, "Warehouse;
inventoryList.addGuitarguitar;
Guitar lookingGuitar inventoryList.searchGuitarFenderAH;
if lookingGuitar null
System.out.printlnbrand: lookingGuitar.brand model: lookingGuitar.model color: lookingGuitar.color isSecondhand: lookingGuitar.isSecondHand price: lookingGuitar.price Warehouse: lookingGuitar.warehouse Stock: lookingGuitar.stockNumber;
else
System.out.printlnGuitar not exist";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started