I am really programming illiterate. I have no idea how to create the Form for th
ID: 3778289 • Letter: I
Question
I am really programming illiterate. I have no idea how to create the Form for this question. Therefore I am lost on where to even start with coding. Here is the problem. I need this for C# and that is my problem.
RetailItem Class
Write a class named RetailItem that holds data about an item in a retail store. The
class should have the following properties:
• Description —The Description property should hold a brief description of the
item.
• UnitsOnHand —The UnitsOnHand property should hold the number of units
currently in inventory.
• Price —The Price property should hold the item’s retail price.
Write a constructor that accepts arguments for each property.
The application should create an array of three RetailItem objects containing the
following data:
Description Units on Hand Price
Item 1 Jacket 12 59.95
Item 2 Jeans 40 34.95
Item 3 Shirt 20 24.95
The application should have a loop that steps through the array, displaying each
element’s properties.
Explanation / Answer
Below is the code for the question:-
public class RetailItem
{
//declare variables
private String description;
private int unitsOnHand;
private double price;
//RetailIem class constructor
public RetailItem()
{
description = " ";
unitsOnHand = 0;
price = 0.00;
}
public RetailItem(String description, int unitsOnHand, double price)
{
setDescription(description);
setUnitsOnHand(unitsOnHand);
setPrice(price);
}
/* Method: setDescription
@param unitDescription The descriptions of the retail items.
*/
public void setDescription(String unitDescription)
{
description = unitDescription;
}
public void setUnitsOnHand(int units)
{
unitsOnHand = units;
}
public void setPrice(double thePrice)
{
price = thePrice;
}
public String getDescription()
return description;
}
public int getUnitsOnHand()
{
return unitsOnHand;
}
public double getPrice()
{
return price;
}
public String toString()
{
return "Items Sold: ";
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.