Question
import java.util.ArrayList; public class Catalog { private ArrayList catalogItems; public static int count; public Catalog() { catalogItems = new ArrayList (); count = 0; }
import java.util.ArrayList;
public class Catalog {
private ArrayList
public static int count;
public Catalog() {
catalogItems = new ArrayList
count = 0;
}
public void add (CatalogItem catalogItem) {
if (count < 100) {
catalogItems.add(catalogItem);
count++;
} else {
System.out.println("No more capacity to add catalog item");
}
}
public void add (int itemID, String description, double priceValue) {
if (count < 100) {
CatalogItem catalogItem = new CatalogItem(itemID, description, priceValue);
catalogItems.add(catalogItem);
count++;
} else {
System.out.println("No more capacity to add catalog item");
}
}
public void update (int itemID, String description) {
for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); if (catalogItem.getItemId() == itemID) { catalogItem.setDescription(description); break; } } } public void update (int itemID, double priceValue) { for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); if (catalogItem.getItemId() == itemID) { catalogItem.setPriceValue(priceValue); break; } } } public void priceIncrease(double percentageAmount ) { for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); double newPriceValue = (catalogItem.getPriceValue() * percentageAmount) + catalogItem.getPriceValue(); catalogItem.setPriceValue(newPriceValue); } } public CatalogItem getCatalogItem (int itemID) { for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); if (catalogItem.getItemId() == itemID) { return catalogItem; } } return null; } public void display() { if (count > 0) { System.out.println(" The Catalog consists of "+count+" items."); for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); System.out.println(catalogItem); } } else { System.out.println(" The Catalog consists of 0 items."); } } @Override public String toString() { String output = " The Catalog consists of "+count+" items. "; for (int i=0;i CatalogItem catalogItem = catalogItems.get(i); output = output + catalogItem + " "; } return output; } } *********************************** public class CatalogItem { private int itemID; private String description; private double priceValue; public CatalogItem() { this.itemID = 0; this.description = ""; this.priceValue = 0; } public CatalogItem(int itemID, String description, double priceValue) { this.itemID = itemID; this.description = description; this.priceValue = priceValue; } public CatalogItem(CatalogItem catalogItem) { this.itemID = catalogItem.itemID; this.description = catalogItem.description; this.priceValue = catalogItem.priceValue; } public int getItemId() { return itemID; } public String getDescription() { return description; } public double getPriceValue() { return priceValue; } public void setDescription(String description) { this.description = description; } public void setPriceValue(double priceValue) { this.priceValue = priceValue; } @Override public String toString() { return "Item: " + itemID + ", " + description + ". Price: $" + String.format("%.2f", priceValue); } } can you put javadocs doumentation and see if there are any == methods that can be replaced with .equals methods ? thank you
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