Points Possible 100 In this assignment we are look and Object-Oriented Programming concepts. You have been requested to develop the logic for program to process a class called Retailltem. This class contains the following attributes: item description, units in inventory, and price. This class is also suppose to contain the following methods A method named purchase_item that used to purchase an item from the inventory A method named get_total that recovers the cost of an item method show_item that display the description of a item and its cost A With the above information draw UML diagram. When you complete them drop them into the assignment dropbox.
Expert Answer
public class RetailItem {
private String itemDesc;
private int units;
private double price;
/**
* @param itemDesc
* @param units
* @param price
*/
public RetailItem(String itemDesc, int units, double price) {
this.itemDesc = itemDesc;
this.units = units;
this.price = price;
}
/**
* @return the itemDesc
*/
public String getItemDesc() {
return itemDesc;
}
/**
* @return the units
*/
public int getUnits() {
return units;
}
/**
* @return the price
*/
public double getPrice() {
return price;
}
/**
* @param itemDesc
* the itemDesc to set
*/
public void setItemDesc(String itemDesc) {
this.itemDesc = itemDesc;
}
/**
* @param units
* the units to set
*/
public void setUnits(int units) {
this.units = units;
}
/**
* @param price
* the price to set
*/
public void setPrice(double price) {
this.price = price;
}
public void purchase_item() {
// provide the spec
}
public double get_total() {
// provide the spec
return this.price;
}
public void show_item() {
System.out.println(toString());
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return “RetailItem [itemDesc=” + itemDesc + “, units=” + units
+ “, price=” + price + “]”;
}
}
UML CLASS DIAGRAM: