C# Computer Order program

Jun 13 2015 2:19 AM
Hi, i am new on C# and am trying to code this program, this is my last class to graduate and i need help.
here i send you the objective of the program.
 

CIS1280 C# /.NET I

Program 2 Computer Order Class, Due: Wednesday, June 17, 2015

Objective: Write a simple user-defined class and test it

Training Objectives:

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.

Turn in requirements:

  1. Please name your Program LastnameP1, such as NelsonP1.

  2. Check your code into source control.

  3. Upload your QA checklist to blackboard

Program Requirements:

  1. 3 pts Write your name, email address and file name at the top of your source code in a comment.

  2. 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.

  3. 5 pts Use good C# programming style and formatting for your program.

  4. 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:

  1. Instantiate a ComputerOrder object.

  2. 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.

  3. 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.


  1. Finally, call GetOrderSummary and display the motherboard, memory ordered, size of hard drive, the peripherals ordered, and the price.

  2. Finally, ask the user if he/she wants to order another computer.

When done, display a good-bye message.




//////    And this is what have so far:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace AbesoP2
{

class ComputerOrder
{

#region
private int mboardOptionIndex; // holds indexes
private static string[] mboardOptions;
private static double[] mboardPrice; // holds all the prices

int memoryOptionIndex;
static string[] memoryOptions;
static double[] memoryPrice;

int[] driveOptionIndex;
static string[] driveOption;
static double[] drivePrice;

private List<int> periphList;
static string periphOption; // have at least 5
static float periphPrice; // Store the cost of each peripheral

double totalPrice;
int value;

/* string peripheralsMenu;
string motherboardsMenu;
string memoryMenu;
string driveMenu;
string OrderSummaryMenu;*/
#endregion

public ComputerOrder()
{

string[] mboardOptions = new string[3];
mboardOptions[0] = "AT Motherboard";
mboardOptions[1] = "ATX Motherboard";
mboardOptions[2] = "LPX Motherboard";

string[] memoryOptions = new string[3];
memoryOptions[0] = "2GB Ram";
memoryOptions[1] = "4GB Ram";
memoryOptions[2] = "6GB Ram";

string[] periphOption = new string[5];
periphOption[0] = "Keyboard";
periphOption[1] = "Monitor";
periphOption[2] = "Mouse";
periphOption[3] = "Dvd-drive";
periphOption[4] = "Video-card";

string[] driveOption = new string[3];
driveOption[0] = "250GB";
driveOption[1] = "500GB";
driveOption[2] = "750GB";

double[] mboardPrice = new double[3];
mboardPrice[0] = 125.00;
mboardPrice[1] = 200.00;
mboardPrice[2] = 350.00;

double[] memoryPrice = new double[3];
memoryPrice[0] = 10.00;
memoryPrice[1] = 15.00;
memoryPrice[2] = 25.00;

double[] drivePrice = new double[3];
drivePrice[0] = 30.00;
drivePrice[1] = 65.00;
drivePrice[2] = 90.00;

float[] periphPrice = new float[3];
periphPrice[0] = 70.0F;
periphPrice[1] = 130.0F;
periphPrice[2] = 35.0F;
periphPrice[3] = 90.0F;
periphPrice[4] = 80.0F;



List<string> periphList = new List<String>();
periphList.Add("1- Keyboard ");
periphList.Add("2- Monitor");
periphList.Add("3- DVD-Drive");
periphList.Add("4- Mouse");
periphList.Add("5- Video-card");



#region
Console.WriteLine("||=====================================================================================||");
Console.WriteLine("|| Welcome to the C# Computer Company! We sell computers ||");
Console.WriteLine("|| You can chose from one of the three diferent processor/motherboards ||");
Console.WriteLine("|| combinations, the amount of on-board memory, size of hard drive, and number ||");
Console.WriteLine("|| of peripherals(DVD drive, Mouse, Keyboards, Monitor, Video-Card) ||");
Console.WriteLine("||=====================================================================================||");
Console.WriteLine();
Console.WriteLine("||=====================================================================================||");
Console.WriteLine("|| Motherboards || HARD-DRIVE || MEMORY || PERIPHERALS ||");
Console.WriteLine("||=====================================================================================||");
Console.WriteLine("|| Model | Price || Model | Price || Type | Price || Item | Price ||");
Console.WriteLine("||=====================================================================================||");
Console.WriteLine("|| AT Mother | $125.00 || 250GB | $30.00 || 2GB RAM | $10.00 || Keyboard | $70.00 ||");
Console.WriteLine("|| ATX Mother | $200.00 || 500GB | $65.00 || 4GB RAM | $15.00 || Monitor | $130.00 ||");
Console.WriteLine("|| LPX Mother | $350.00 || 750GB | $90.00 || 6GB RAM | $25.00 || Mouse | $35.00 ||");
Console.WriteLine("||-------------------------------------------------------------|| DVD-DRIVE | $90.00 ||");
Console.WriteLine("|| || VIDEO-CARD | $80.00 ||");
Console.WriteLine("||=====================================================================================||");
Console.WriteLine();
#endregion



public void SetMboardOptionIndex(int mboardOption)
{

}


public void SetMemoryOptionIndex(int memoryOption)
{

}


public void SetPeriphOptionIndex(int periphList)
{


}


public void setDriveOPtionIndex(int driveOption)
{


}

public void SetPeriphList(int periphList)
{

}


// Getting indexes

public string GetMboardOptionIndex
{

}


public string GetDriveOptionIndex
{

}


public string GetPeriphList
{


}


public string GetOrderSummary
{



}



private void CalculatePrice()
{
double totalPrice;


do{

totalPrice = mboardPrice + drivePrice +
memoryPrice + periphPrice;
// will requiere a loop
// here is where we do all the calculation
//enter 90 to stop

} while()
}


}


public static void Main()
{

ComputerOrder cO = new ComputerOption();
// Motherboard options
Console.WriteLine("Chose you Motherboard type by index ");
mboardOptionIndex = Convert.ToInt32(Console.ReadLine());

//Memory options
Console.Write("Select Memory capacity ");
memoryOptionIndex = Convert.ToInt32(Console.ReadLine());


//Hard drive Selection
Console.WriteLine("Select Hard Drive");
driveOptionIndex = Convert.ToInt32(Console.ReadLine());

// Memory size selection
Console.WriteLine("Select your Drive ");
memoryOptionIndex = Convert.ToInt32(Console.ReadLine());

// Peripherials selection
Console.WriteLine("Chose all Peripherals you need");
periphList = Convert.ToInt32(Console.ReadLine());

}
}
 
 
 
 

Answers (2)