CIS1280 C# /.NET I
Program 2 Computer Order Class, Due: Wednesday, June 17, 2015
Objective: Write a simple user-defined class and test it
Keywords, data types, strongly typed language, conditional structures, loops, getting data to/from keyboard, formatting. Using methods, accessibility, and static modifier. OOP. Creating a user-defined class, methods, calling instance methods. Constructors. Parameterless. Public and private access.
Please name your Program LastnameP1, such as NelsonP1.
Check your code into source control.
Upload your QA checklist to blackboard
3 pts Write your name, email address and file name at the top of your source code in a comment.
5 pts. Use Console.WriteLine statements to write your name, program title, and program objective to the screen so that it is the first thing I see when your program runs. This is your header.
5 pts Use good C# programming style and formatting for your program.
5 pts Use appropriate comments to explain what you are doing.
Welcome to the C# Computer Company! We sell computers. You can choose from one of three different processor/motherboard combinations, the amount of on-board memory, size of hard drive and any number of peripherals (dvd drive, mouse, keyboards, etc.).
Write a class named ComputerOrder. It will reside the file named ComputerOrder.cs.
Include these private data fields:
An instance int called mboardOptionIndex for motherboard selected
A static string array called mboardOptions that has descriptions of motherboard options
A static double array called mboardPrice that has the cost of each motherboard option
An instance int called memoryOptionIndex for on board memory option selected
A static string array called memoryOptions that has descriptions of memory options
A static double array called memoryPrice that has the cost of each memory option
An instance int called driveOptionIndex for hard drive option selected
A static string array called driveOptions that has descriptions of drive options
static double array called drivePrice that has the cost of each drive option
An instance list<int> object called periphList for peripherals user selected. This list will accumulate the indices of the peripherals ordered.
A static string array called periphOptions to store the names of peripherals available (have at least five)
A static float array called periphPrice store the cost of each peripheral
An instance double called totalPrice for total price of the computer
Other fields as needed
This class will have the following:
A public default constructor.
Public set methods for each of the instance data fields except the totalPrice. Each set method that may change the cost of the computer must call the CalculatePrice() method below to recalculate the totalPrice field. Set methods should do only two things: set the new value into the appropriate field and then call CalculatePrice() if needed to adjust totalPrice.
Public get methods for all of the fields. DO NOT call CalculatePrice() from get methods. Also DO NOT do any calculation in the get method. Get methods should simply return the value currently in the field they are associated with.
A public, parameterless string method called GetPeripheralsMenu() that will return a nicely formatted string that can be used to display a menu of all the peripherals options with their prices. Create similar methods for creating menus to select the motherboard, memory and drive options.
A public, parameterless string method called GetOrderSummary() that will return a nicely formatted string that summarizes the order including options selected and total price.
A private void CalculatePrice() method the calculates price based on the motherboard selected, memory selected, the hard drive selected and the peripherals selected (this will require a loop). The CalculatePrice() method must be called from each of the appropriate set methods. DO NOT do calculations anywhere else except in the private void CalculatePrice() method!
Rename your Program.cs TestComputerOrder.cs. In Main, present your header, then open a do-while or while loop for ordering computers that does the following:
Instantiate a ComputerOrder object.
For motherboard, memory and drive options: Display a menu showing options. Ask the user to select an option. Call the appropriate class set method. The object’s set method should automatically call the CalculatePrice method to update the price.
Then create an integer list (list<int>) object called periphOrderList. Begin a loop that allows the user to order as many peripherals as desired. Stop the ordering with a sentinel value (0 or -99 for example). Each time a peripheral is ordered add it to the periphOrderList using the List.Add() method. After the user enters the sentinel value, use ComputerOrder object’s SetPeriphList method to set periphOrderList into the CompterOrder object. The object’s set method should automatically call the CalculatePrice method to update the price.
Finally, call GetOrderSummary and display the motherboard, memory ordered, size of hard drive, the peripherals ordered, and the price.
Finally, ask the user if he/she wants to order another computer.
When done, display a good-bye message.