Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You run Mohawk Microcomputers, a shop that does microcomputer builds and repairs. Each month you must generate your Accounts Payable invoice, and pay for the
You run Mohawk Microcomputers, a shop that does microcomputer builds and repairs. Each month you must generate your Accounts Payable invoice, and pay for the parts and labour used. Look over the following UML diagram (Links to an external site.) carefully (marks are shown for each entity):
You are to write the code for all of the shown components, obeying the following guidelines:
- Do not write unnecessary code. All methods and instance variables are in the UML.
- Your classes must make use of reusable code where possible. Use best practices.
- The Part constructor must throw an appropriate exception (with custom message) if either the quantity or cost is not a positive amount.
- The Labour constructor must throw an appropriate exception (with custom message) if the price is not a positive amount.
- The Invoice class must use a single List<> to store all polymorphic objects.
- Process the List<> using a loop:
- A Part is billed the quantity times the cost.
- A Labour task is billed just the single price.
- Before an item is processed, it must be validated:
- A Part is valid if the 6-digit PartID starts with 14, 15, 16, or 17.
- A Labour task is valid if the LabourID is one of Install, Replace, or Dispose.
- The program output should neatly incorporate the following:
- A report title for this months Accounts Payable.
- Each line item, using the classes ToString() methods with all of the class data.
- Each line items total cost, if it has a valid ID, otherwise display an error message.
- A grand total of all costs as a summary line.
- Dollar values are to be displayed as currency.
- Hardcode the following object data into your Main() method (no user input required):
- Part: [PartID: 152398, Description: "16GB RAM", Quantity: 2, Cost: $95.99]
- Part: [PartID: 126523, Description: "Cooling Fan", Quantity: 1, Cost: $45.89]
- Labour: [LabourID: "Install", Detail: "RAM", Price: $25.89]
- Labour: [LabourID: "Eat", Detail: "Cooling Fan", Price: $25.89]
- Part: [PartID: 178834, Description: "Network Adaptor", Quantity: 1, Cost: $165.25]
- Labour: [LabourID: "Replace", Detail: "Cooling Fan", Price: $25.89]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started