Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 catalogItems;

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What is the problem asking me?

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago