Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class in C# windows form named RetailItem that holds data about an item

ID: 3843652 • Letter: W

Question

Write a class in C# windows form 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

Jacker

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 elements properties.

Use methods, button event, and rich text field as necessary.

Description

Units on Hand

Price

Item 1

Jacker

12

59.95

Item 2

Jeans

40

34.95

Item 3

Shirt

20

24.95

Explanation / Answer

// Program to print array elements
using System;
namespace RetailitemApplication
{
class Retailitem // create class
{
public string description;   
public int unitsonhand;
public double price;

// constructor

public Retailitem(string s, int i, double d) {
description = s;
unitsonhand = i;
price = d;
}
}
class RetailItemTest
{
static void Main ()
{
Console.WriteLine("RetailItemTest item printing");
Console.WriteLine("");
Retailitem item1 = new Retailitem("Jacket", 12, 59.95); // objects of class
Retailitem item2 = new Retailitem("Jeans", 40, 34.95);
Retailitem item3 = new Retailitem("Shirt", 20, 24.95);
Retailitem [] allItems = new Retailitem[3];
allItems[0] = item1;
allItems[1] = item2;
allItems[2] = item3;
Retailitem testItem1 = null;
for (int i = 0; i < 3; i++)
{
testItem1 = allItems[i];
Console.WriteLine("Retailitem " + i + "=" + testItem1.description + " " + testItem1.unitsonhand + " " + testItem1.price);
}

// Keep the console window open in debug mode.
Console.WriteLine ( "Press any key to exit." );
Console.ReadKey ();
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote