It's a windows application of a Restaurant Cash Register
The selected items from each category (listBox1 and listBox3) are copied on listBox2. How can i sum the items on listBox2 and make it display it on the textBox1 below?
Thanks,
****************
This is my DLL:
using System;
namespace ClassLibrary1
{
/// <summary>
/// Food class that holds the name and the price of a single food item.
/// Regular Menu class and Kid Menu Class that inherits from the Food class.
/// Choices class which contain an array of Regular Menu and/or Kid Menu objects.
/// </summary>
// parent class
public class Food
{ // starts class food
public string name;
public double price;
public Food() // default constructor - initializes name and price to its lowest values.
{
name = " ";
price = 0.00;
}
public Food( string iName, double iPrice) // constructor takes two arguments of type string & double
{
name = iName;
price = iPrice;
}
public string iName // functions set and get for iName
{
get
{
return name;
}
set
{
name = value;
}
}
public double iPrice // functions set and get for iPrice
{
get
{
return price;
}
set
{
price = value;
}
}
} //ends class Food
public class RegularMenu : Food // starts class RegularMenu which inherits from class Food
{
public RegularMenu(string iName, double iPrice) // constructor takes two arguments of type string & double
{
name = iName;
price = iPrice;
}
} // ends class RegularMenu
public class KidMenu : Food // starts class KidMeni which inherits from class Food
{
public KidMenu(string iName, double iPrice) // constructor takes two arguments of type string & double
{
name= iName;
price = iPrice;
}
} // ends class KidMenu
public class Selection // starts class Selection
{
// arrays of objects of RegularMenu and KidMenu
private RegularMenu[] rmenu = new RegularMenu[50];
private KidMenu[] kmenu = new KidMenu[50];
private int sizeRegmenu =0;
private int sizeKidmenu =0;
public int sizereg // get/set functions
{
get
{
return sizeRegmenu;
}
}
public int sizekid
{
get
{
return sizeKidmenu;
}
}
public Selection()
{
rmenu[0]= new RegularMenu("pizza slice", 2.50);
rmenu[1]= new RegularMenu("hamburguer", 1.75);
rmenu[2]= new RegularMenu("salad", 1.90);
rmenu[3]= new RegularMenu("large soda", 1.20);
rmenu[4]= new RegularMenu("medium soda", 0.90);
sizeRegmenu = 5;
kmenu[0]=new KidMenu("hot dog", 1.50);
kmenu[1]= new KidMenu("small soda", 0.60);
kmenu[2]= new KidMenu("cookie", 0.86);
sizeKidmenu =3;
}
public void add_rmenu( RegularMenu m)
{
rmenu[++ sizeRegmenu] = m;
}
public void add_kid(KidMenu m)
{
kid[++sizeKidmenu] = m;
}
}
}
------------------------
This is the code right now but it gives me some errors. I think i should put the class Selections (That's on the DLL) on the code, but im not sure and i did it and it still gave me some errors.. Can someone help me?:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ClassLibrary3; // dll created
namespace WindowsApplication1
{
/// <summary>
/// Program that will allow to pick several items from two different menus; RegularMenu
/// and KidMenu and will prepare a Custom Order for the customer.
/// At the end, it will display the total to be paid.
/// It will also allow the user to clear the form and/or click the Quit button and decide
/// what to do with the order.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.ListBox listBox3;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.PictureBox pictureBox1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label7 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label4 = new System.Windows.Forms.Label();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button1 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.listBox3 = new System.Windows.Forms.ListBox();
this.listBox2 = new System.Windows.Forms.ListBox();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label5 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.button4);
this.groupBox1.Controls.Add(this.button3);
this.groupBox1.Controls.Add(this.button2);
this.groupBox1.Controls.Add(this.button1);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.listBox3);
this.groupBox1.Controls.Add(this.listBox2);
this.groupBox1.Controls.Add(this.listBox1);
this.groupBox1.Location = new System.Drawing.Point(16, 104);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(632, 312);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
//
// label7
//
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label7.Location = new System.Drawing.Point(272, 288);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(88, 16);
this.label7.TabIndex = 13;
this.label7.Text = "Staff: Mar-Iam ";
//
// label6
//
this.label6.BackColor = System.Drawing.SystemColors.Window;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label6.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.label6.Location = new System.Drawing.Point(256, 72);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(104, 16);
this.label6.TabIndex = 12;
this.label6.Text = "Description Price";
this.label6.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// textBox1
//
this.textBox1.BackColor = System.Drawing.SystemColors.Control;
this.textBox1.Location = new System.Drawing.Point(536, 264);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(80, 20);
this.textBox1.TabIndex = 11;
this.textBox1.Text = "";
//
// label4
//
this.label4.Location = new System.Drawing.Point(472, 264);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(56, 23);
this.label4.TabIndex = 10;
this.label4.Text = "Total:";
//
// button4
//
this.button4.Location = new System.Drawing.Point(112, 264);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(64, 24);
this.button4.TabIndex = 9;
this.button4.Text = "Quit";
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Location = new System.Drawing.Point(24, 264);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(64, 24);
this.button3.TabIndex = 8;
this.button3.Text = "Clear";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(400, 120);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(56, 24);
this.button2.TabIndex = 7;
this.button2.Text = "<<";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// button1
//
this.button1.Location = new System.Drawing.Point(168, 120);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(56, 24);
this.button1.TabIndex = 6;
this.button1.Text = ">>";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label3
//
this.label3.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label3.Location = new System.Drawing.Point(480, 24);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(136, 23);
this.label3.TabIndex = 5;
this.label3.Text = "Kids Menu";
this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// label2
//
this.label2.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label2.Location = new System.Drawing.Point(248, 24);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(136, 23);
this.label2.TabIndex = 4;
this.label2.Text = "Custom Order";
this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// label1
//
this.label1.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label1.Location = new System.Drawing.Point(24, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(128, 23);
this.label1.TabIndex = 3;
this.label1.Text = "Regular Menu";
this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// listBox3
//
this.listBox3.Items.AddRange(new object[] {
"hot dog ($1.50)",
"small soda ($0.60)",
"cookie ($0.86)"});
this.listBox3.Location = new System.Drawing.Point(480, 64);
this.listBox3.Name = "listBox3";
this.listBox3.Size = new System.Drawing.Size(136, 160);
this.listBox3.TabIndex = 2;
//
// listBox2
//
this.listBox2.Items.AddRange(new object[] {
"",
"",
""});
this.listBox2.Location = new System.Drawing.Point(248, 64);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(136, 160);
this.listBox2.TabIndex = 1;
//
// listBox1
//
this.listBox1.Items.AddRange(new object[] {
"pizza slice ($2.50)",
"burger ($1.75)",
"salad ($1.90)",
"large soda ($1.20)",
"medium soda ($0.90)"});
this.listBox1.Location = new System.Drawing.Point(16, 64);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(136, 160);
this.listBox1.TabIndex = 0;
//
// label5
//
this.label5.Font = new System.Drawing.Font("Edwardian Script ITC", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.label5.Location = new System.Drawing.Point(176, 8);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(344, 48);
this.label5.TabIndex = 1;
this.label5.Text = "Restaurant Cash Register";
this.label5.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(264, 56);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(200, 40);
this.pictureBox1.TabIndex = 2;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(664, 430);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label5);
this.Controls.Add(this.groupBox1);
this.Name = "Form1";
this.Text = "Form1";
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
// >> add button from Regular Menu
private void button1_Click(object sender, System.EventArgs e)
{
listBox2.Items.Add (listBox1.SelectedItem);
double total = 0.00;
for (int r=0; r<5; r++)
{
if (listBox1.SelectedItems.Equals(RegularMenu[r].getName()))
{
total += RegularMenu[r].getPrice();
textBox1.Text = String.Format("${0:0.00}", total);
}
} // ends for loop
}
// << add button from Kids Menu
private void button2_Click(object sender, System.EventArgs e)
{
listBox2.Items.Add (listBox3.SelectedItem);
double total = 0.00;
for (int r=0; r<3; r++)
{
if (listBox1.SelectedItems.Equals(KidMenu[r].getName()))
{
total += KidMenu[r].getPrice();
textBox1.Text = String.Format("${0:0.00}", total);
}
}
}
// clears all selected items from the Custom Menu
private void button3_Click(object sender, System.EventArgs e)
{
listBox2.Items.Clear();
}
// quit
private void button4_Click(object sender, System.EventArgs e)
{
DialogResult res = MessageBox.Show("Are you sure you want to quit your order?", "Quit Order",
MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
switch (res)
{
case DialogResult.Yes:
// application will exit
listBox2.Items.Clear();
textBox1.Clear();
break;
case DialogResult.No:
// will return to the main application
return;
}
}
/* WHAT I TRIED AT FIRST TO CALCULATE THE SUM
*
public int getPrice( ListBox aList )
{
int startIndex = 0;
int endIndex = 0;
string subString;
startIndex = aList.Text.LastIndexOf("$"); // give me the index at char "$"
endIndex = aList.Text.LastIndexOf("]"); // give me the index at char "]"
subString = aList.Text.Substring(startIndex + 1, (endIndex - 1) - startIndex);
return Convert.ToInt16(subString);
}
public void calculatePrice()
{ // begins calculatePrice
//listBox2.Items.Add (listBox3.SelectedItem);
double totalPrice = 0.00;
totalPrice += getPrice(listBox2);
textBox1.Text = totalPrice.ToString();
} // end calculatePrice
*/
}
}
Nothing is stopping you from continuing with your testing cadence.
If updates are released every 2 weeks instead of 4, and you test once every 4 weeks, the exact same amount of patches will still be available for you in those 4 weeks.
For example:
Before
4th week - patch 1, 2, 3, 4
After
2nd week - patch 1 and 2
4th week - patch 3 and 4
Still the same amount after 4.
Everyone else has said it. I'm gonna say it - you don't know what you're talking about.
I do. I have two laptops. One work, one personal. I have access to two more laptops - both personal. At home I manually update my personal laptop when I see on Neowin that there is an update - I carry on and only apply the updates when I am ready. My work one only updates when my workplace decides to send it - I carry on and only apply the updates (when they actually arrive, which is usually days after the release) when I switch off the laptop at the end of the day as usual. The two other personal laptops only get updated when I get to it which is rarely - the people who own them carry on using them until I get to it and update them.
All of the browsers on all laptops are configured to restore the tabs when launched.
Google and Microsoft have changed from 6 weeks to 4, and it looks like it's going to move to 2. None of these changes affect how any of these browsers on the laptops are used. Not one jot.
My advice to you is stop panicking whenever you see an update. Just carry on with what you're doing. This even benefits you in a way - from your comment you sound like you don't like the changes or the frivolous new features - great - then carry on as before!
Question
marie
I have a code and a dll that i made.
It's a windows application of a Restaurant Cash Register
The selected items from each category (listBox1 and listBox3) are copied on listBox2. How can i sum the items on listBox2 and make it display it on the textBox1 below?
Thanks,
****************
This is my DLL:
using System; namespace ClassLibrary1 { /// <summary> /// Food class that holds the name and the price of a single food item. /// Regular Menu class and Kid Menu Class that inherits from the Food class. /// Choices class which contain an array of Regular Menu and/or Kid Menu objects. /// </summary> // parent class public class Food { // starts class food public string name; public double price; public Food() // default constructor - initializes name and price to its lowest values. { name = " "; price = 0.00; } public Food( string iName, double iPrice) // constructor takes two arguments of type string & double { name = iName; price = iPrice; } public string iName // functions set and get for iName { get { return name; } set { name = value; } } public double iPrice // functions set and get for iPrice { get { return price; } set { price = value; } } } //ends class Food public class RegularMenu : Food // starts class RegularMenu which inherits from class Food { public RegularMenu(string iName, double iPrice) // constructor takes two arguments of type string & double { name = iName; price = iPrice; } } // ends class RegularMenu public class KidMenu : Food // starts class KidMeni which inherits from class Food { public KidMenu(string iName, double iPrice) // constructor takes two arguments of type string & double { name= iName; price = iPrice; } } // ends class KidMenu public class Selection // starts class Selection { // arrays of objects of RegularMenu and KidMenu private RegularMenu[] rmenu = new RegularMenu[50]; private KidMenu[] kmenu = new KidMenu[50]; private int sizeRegmenu =0; private int sizeKidmenu =0; public int sizereg // get/set functions { get { return sizeRegmenu; } } public int sizekid { get { return sizeKidmenu; } } public Selection() { rmenu[0]= new RegularMenu("pizza slice", 2.50); rmenu[1]= new RegularMenu("hamburguer", 1.75); rmenu[2]= new RegularMenu("salad", 1.90); rmenu[3]= new RegularMenu("large soda", 1.20); rmenu[4]= new RegularMenu("medium soda", 0.90); sizeRegmenu = 5; kmenu[0]=new KidMenu("hot dog", 1.50); kmenu[1]= new KidMenu("small soda", 0.60); kmenu[2]= new KidMenu("cookie", 0.86); sizeKidmenu =3; } public void add_rmenu( RegularMenu m) { rmenu[++ sizeRegmenu] = m; } public void add_kid(KidMenu m) { kid[++sizeKidmenu] = m; } } }------------------------
This is the code right now but it gives me some errors. I think i should put the class Selections (That's on the DLL) on the code, but im not sure and i did it and it still gave me some errors.. Can someone help me?:
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using ClassLibrary3; // dll created namespace WindowsApplication1 { /// <summary> /// Program that will allow to pick several items from two different menus; RegularMenu /// and KidMenu and will prepare a Custom Order for the customer. /// At the end, it will display the total to be paid. /// It will also allow the user to clear the form and/or click the Quit button and decide /// what to do with the order. /// </summary> public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.ListBox listBox1; private System.Windows.Forms.ListBox listBox2; private System.Windows.Forms.ListBox listBox3; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Label label4; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.Label label5; private System.Windows.Forms.Label label6; private System.Windows.Forms.Label label7; private System.Windows.Forms.PictureBox pictureBox1; private System.ComponentModel.IContainer components; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.label7 = new System.Windows.Forms.Label(); this.label6 = new System.Windows.Forms.Label(); this.textBox1 = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.listBox3 = new System.Windows.Forms.ListBox(); this.listBox2 = new System.Windows.Forms.ListBox(); this.listBox1 = new System.Windows.Forms.ListBox(); this.label5 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.label7); this.groupBox1.Controls.Add(this.label6); this.groupBox1.Controls.Add(this.textBox1); this.groupBox1.Controls.Add(this.label4); this.groupBox1.Controls.Add(this.button4); this.groupBox1.Controls.Add(this.button3); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Controls.Add(this.label3); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.label1); this.groupBox1.Controls.Add(this.listBox3); this.groupBox1.Controls.Add(this.listBox2); this.groupBox1.Controls.Add(this.listBox1); this.groupBox1.Location = new System.Drawing.Point(16, 104); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(632, 312); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; // // label7 // this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label7.Location = new System.Drawing.Point(272, 288); this.label7.Name = "label7"; this.label7.Size = new System.Drawing.Size(88, 16); this.label7.TabIndex = 13; this.label7.Text = "Staff: Mar-Iam "; // // label6 // this.label6.BackColor = System.Drawing.SystemColors.Window; this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label6.ImageAlign = System.Drawing.ContentAlignment.TopLeft; this.label6.Location = new System.Drawing.Point(256, 72); this.label6.Name = "label6"; this.label6.Size = new System.Drawing.Size(104, 16); this.label6.TabIndex = 12; this.label6.Text = "Description Price"; this.label6.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // textBox1 // this.textBox1.BackColor = System.Drawing.SystemColors.Control; this.textBox1.Location = new System.Drawing.Point(536, 264); this.textBox1.Name = "textBox1"; this.textBox1.Size = new System.Drawing.Size(80, 20); this.textBox1.TabIndex = 11; this.textBox1.Text = ""; // // label4 // this.label4.Location = new System.Drawing.Point(472, 264); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(56, 23); this.label4.TabIndex = 10; this.label4.Text = "Total:"; // // button4 // this.button4.Location = new System.Drawing.Point(112, 264); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(64, 24); this.button4.TabIndex = 9; this.button4.Text = "Quit"; this.button4.Click += new System.EventHandler(this.button4_Click); // // button3 // this.button3.Location = new System.Drawing.Point(24, 264); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(64, 24); this.button3.TabIndex = 8; this.button3.Text = "Clear"; this.button3.Click += new System.EventHandler(this.button3_Click); // // button2 // this.button2.Location = new System.Drawing.Point(400, 120); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(56, 24); this.button2.TabIndex = 7; this.button2.Text = "<<"; this.button2.Click += new System.EventHandler(this.button2_Click); // // button1 // this.button1.Location = new System.Drawing.Point(168, 120); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(56, 24); this.button1.TabIndex = 6; this.button1.Text = ">>"; this.button1.Click += new System.EventHandler(this.button1_Click); // // label3 // this.label3.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label3.Location = new System.Drawing.Point(480, 24); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(136, 23); this.label3.TabIndex = 5; this.label3.Text = "Kids Menu"; this.label3.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // label2 // this.label2.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label2.Location = new System.Drawing.Point(248, 24); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(136, 23); this.label2.TabIndex = 4; this.label2.Text = "Custom Order"; this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // label1 // this.label1.Font = new System.Drawing.Font("Eras Light ITC", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label1.Location = new System.Drawing.Point(24, 24); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(128, 23); this.label1.TabIndex = 3; this.label1.Text = "Regular Menu"; this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // listBox3 // this.listBox3.Items.AddRange(new object[] { "hot dog ($1.50)", "small soda ($0.60)", "cookie ($0.86)"}); this.listBox3.Location = new System.Drawing.Point(480, 64); this.listBox3.Name = "listBox3"; this.listBox3.Size = new System.Drawing.Size(136, 160); this.listBox3.TabIndex = 2; // // listBox2 // this.listBox2.Items.AddRange(new object[] { "", "", ""}); this.listBox2.Location = new System.Drawing.Point(248, 64); this.listBox2.Name = "listBox2"; this.listBox2.Size = new System.Drawing.Size(136, 160); this.listBox2.TabIndex = 1; // // listBox1 // this.listBox1.Items.AddRange(new object[] { "pizza slice ($2.50)", "burger ($1.75)", "salad ($1.90)", "large soda ($1.20)", "medium soda ($0.90)"}); this.listBox1.Location = new System.Drawing.Point(16, 64); this.listBox1.Name = "listBox1"; this.listBox1.Size = new System.Drawing.Size(136, 160); this.listBox1.TabIndex = 0; // // label5 // this.label5.Font = new System.Drawing.Font("Edwardian Script ITC", 26.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); this.label5.Location = new System.Drawing.Point(176, 8); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(344, 48); this.label5.TabIndex = 1; this.label5.Text = "Restaurant Cash Register"; this.label5.TextAlign = System.Drawing.ContentAlignment.TopCenter; // // pictureBox1 // this.pictureBox1.Location = new System.Drawing.Point(264, 56); this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Size = new System.Drawing.Size(200, 40); this.pictureBox1.TabIndex = 2; this.pictureBox1.TabStop = false; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(664, 430); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.label5); this.Controls.Add(this.groupBox1); this.Name = "Form1"; this.Text = "Form1"; this.groupBox1.ResumeLayout(false); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } // >> add button from Regular Menu private void button1_Click(object sender, System.EventArgs e) { listBox2.Items.Add (listBox1.SelectedItem); double total = 0.00; for (int r=0; r<5; r++) { if (listBox1.SelectedItems.Equals(RegularMenu[r].getName())) { total += RegularMenu[r].getPrice(); textBox1.Text = String.Format("${0:0.00}", total); } } // ends for loop } // << add button from Kids Menu private void button2_Click(object sender, System.EventArgs e) { listBox2.Items.Add (listBox3.SelectedItem); double total = 0.00; for (int r=0; r<3; r++) { if (listBox1.SelectedItems.Equals(KidMenu[r].getName())) { total += KidMenu[r].getPrice(); textBox1.Text = String.Format("${0:0.00}", total); } } } // clears all selected items from the Custom Menu private void button3_Click(object sender, System.EventArgs e) { listBox2.Items.Clear(); } // quit private void button4_Click(object sender, System.EventArgs e) { DialogResult res = MessageBox.Show("Are you sure you want to quit your order?", "Quit Order", MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); switch (res) { case DialogResult.Yes: // application will exit listBox2.Items.Clear(); textBox1.Clear(); break; case DialogResult.No: // will return to the main application return; } } /* WHAT I TRIED AT FIRST TO CALCULATE THE SUM * public int getPrice( ListBox aList ) { int startIndex = 0; int endIndex = 0; string subString; startIndex = aList.Text.LastIndexOf("$"); // give me the index at char "$" endIndex = aList.Text.LastIndexOf("]"); // give me the index at char "]" subString = aList.Text.Substring(startIndex + 1, (endIndex - 1) - startIndex); return Convert.ToInt16(subString); } public void calculatePrice() { // begins calculatePrice //listBox2.Items.Add (listBox3.SelectedItem); double totalPrice = 0.00; totalPrice += getPrice(listBox2); textBox1.Text = totalPrice.ToString(); } // end calculatePrice */ } }Edited by marieLink to comment
https://www.neowin.net/forum/topic/387388-restaurant-cash-register/Share on other sites
3 answers to this question
Recommended Posts