Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if(serialPort1.BytesToRead > 0)
- {
- string color = serialPort1.ReadLine().Trim();
- if(color.StartsWith("WHITE"))
- {
- double wprice = 5;
- Balance[names.IndexOf(tbBuyer.Text)] -= wprice;
- lbx1.Items.Clear();
- foreach (string mate in names)
- {
- lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
- }
- }
- else if (color.StartsWith("BLACK"))
- {
- double bprice = 2;
- Balance[names.IndexOf(tbBuyer.Text)] -= bprice;
- lbx1.Items.Clear();
- foreach (string mate in names)
- {
- lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
- }
- }
- else if (color.StartsWith("RED"))
- {
- double rprice = 3;
- Balance[names.IndexOf(tbBuyer.Text)] -= rprice;
- lbx1.Items.Clear();
- foreach (string mate in names)
- {
- lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
- }
- }
- else if (color.StartsWith("BLUE"))
- {
- double blprice = 4;
- Balance[names.IndexOf(tbBuyer.Text)] -= blprice;
- lbx1.Items.Clear();
- foreach (string mate in names)
- {
- lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
- }
- }
- else if (color.StartsWith("GREEN"))
- {
- double gprice = 1;
- Balance[names.IndexOf(tbBuyer.Text)] -= gprice;
- lbx1.Items.Clear();
- foreach (string mate in names)
- {
- lbx1.Items.Add(mate + "\t" + Balance[names.IndexOf(mate)].ToString("0.00€"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement