Question: In c#,Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice
In c#,Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include six pieces of information as private instance variables a part number (type string), a part name (type string), a part description (type string), a part manufacturer (type string), a quantity of the item being purchased (type int) and a price per item (decimal).
- Provide a property with a get and set accessor for int and decimal variables. For the Quantity and PricePerItem properties, if the value passed to the set accessor is negative, the value of the instance variable should be left unchanged.
- Provide an indexer with a get and set accessor for each string variable.
- Also, provide a method named GetInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a decimal value.
- Write a test class named InvoiceTest that demonstrates class Invoices following capabilities:
* create an instance by calling its default constructor;
* assign the value of each instance variable via the indexers and properties;
* call the method GetInvoiceAmount;
* get the new value of each variable via its property or indexer;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
