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

The purpose of this assignment is to practice introductory C# concepts and class

ID: 3661446 • Letter: T

Question

The purpose of this assignment is to practice introductory C# concepts and classes :

- Process sale orders: For each sale, the user should enter a transaction id, customer name,

delivery address and allow the user to select a shirt size and number of shirts of that size to be

ordered. A customer can order more than one shirt and shirts of different sizes in a given

transaction. The application displays the total charge for the order. Shirt prices are $16 for

sizes S, M, L, and $18 for XS and XL.

- Update order: once a transaction is processed, the application should allow the user to

retrieve a transaction and update the delivery address.

-Generate report: users can view a list of all transactions, total charges for all orders and total

shirts ordered.

The application should implement object-oriented concepts. Create a class to represent the

order. The class should include:

Member variables and properties

Constructors

Methods that have parameters and return values

Loops and conditional statements

Use ToString() method to display order details

Interface may include the following controls:

- Textboxes to get the order details and number of shirts.

- A group of radio buttons for shirt sizes.

- A listbox to display reports.

- Buttons for these functionalities:

Process Order (calculates and displays the charge for the order)

Update Order

View Reports   

You can use an Array or ArrayList to store objects.

Explanation / Answer

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    public void AddOrderLine(string product, int quantity, double price)

    {

        OrderLine line = new OrderLine();

        line.ProductName = product;

        line.Quantity = quantity;

        line.Price = price;

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal();

        }

        return total;

    }

    // Nested class

    private class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal()

        {

            return Price * Quantity;

        }

    }

}

Second Method:

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    public void AddOrderLine(OrderLine line)

    {

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal();

        }

        return total;

    }

    // Nested class

    internal class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal()

        {

            return Price * Quantity;

        }

    }

}

OR

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    private double DiscountMultiplier = 0.85;

    public void AddOrderLine(OrderLine line)

    {

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal(this);

        }

        return total;

    }

    // Nested class

    internal class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal(Order order)

        {

            return Math.Round(Price * Quantity * order.DiscountMultiplier, 2);

        }

    }

}

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    public void AddOrderLine(string product, int quantity, double price)

    {

        OrderLine line = new OrderLine();

        line.ProductName = product;

        line.Quantity = quantity;

        line.Price = price;

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal();

        }

        return total;

    }

    // Nested class

    private class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal()

        {

            return Price * Quantity;

        }

    }

}

Second Method:

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    public void AddOrderLine(OrderLine line)

    {

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal();

        }

        return total;

    }

    // Nested class

    internal class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal()

        {

            return Price * Quantity;

        }

    }

}

OR

class Order

{

    private List<OrderLine> _orderLines = new List<OrderLine>();

    private double DiscountMultiplier = 0.85;

    public void AddOrderLine(OrderLine line)

    {

        _orderLines.Add(line);

    }

    public double OrderTotal()

    {

        double total = 0;

        foreach (OrderLine line in _orderLines)

        {

            total += line.OrderLineTotal(this);

        }

        return total;

    }

    // Nested class

    internal class OrderLine

    {

        public string ProductName { get; set; }

        public int Quantity { get; set; }

        public double Price { get; set; }

        public double OrderLineTotal(Order order)

        {

            return Math.Round(Price * Quantity * order.DiscountMultiplier, 2);

        }

    }

}

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