1
Answer

Test Application

Steph Bassos

Steph Bassos

11y
909
1
What is wrong with this? The red text is what is getting flagged.

using System;

public class Invoice
{
        string partNum;
        string partDesc;
        int quantity;
        double price;

public Invoice(string partNumber, string partDescription, int quantity, double price)
{
        PartNumber = partNum;
        PartDescription = partDesc;
        Quantity = quantity;
        Price = price;
}

public string PartNumber
{
        get { return partNum; }
        set { partNum = value; }
}

public string PartDescription
{
        get { return partDesc; }
        set { partDesc = value; }
}

public int Quantity
{
        get { return quantity; }
       
        set { quantity = value; }
}

public double Price
        {
        get { return price; }
        
        set
        {
        if (value < 0) value = 0;
        price = value;
        }

}

public decimal InvoiceAmount;


//method
public void GetInvoiceAmount(decimal InvoiceAmount)
{
InvoiceAmount =
quantity * price;
}
}

class Test
{
static void Main()
{
Invoice inv = new Invoice("Part 1", "Spool", 10, 9.99);
decimal cost =
inv.GetInvoiceAmount(decimal InvoiceAmount);
Console.WriteLine("Part {0}, Desc {1}, Quantity {2}, Price Each {3:C}, Total Cost {4:C}", inv.PartNumber, inv.PartDescription, inv.Quantity, inv.Price, cost);
Console.ReadKey();
}
}
Answers (1)