Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace sodacrate.cs
  8. {
  9.     class laskback
  10.     {
  11.  
  12.         private string[] sodacrate = new string[24];
  13.         private int antal_flaskor = 0;
  14.  
  15.         public void Run()
  16.         {
  17.             int lask = 1;
  18.             do
  19.             {
  20.                 Console.WriteLine("Välkommen till läskbacken");
  21.  
  22.                 Console.WriteLine(" 1. Lägg till dryck.");
  23.                 Console.WriteLine(" 2. Visa innehåll i backen.");
  24.                 Console.WriteLine(" 3. Beräkna värde för innehållet.");
  25.                 Console.WriteLine(" 4. Avsluta programmet");
  26.  
  27.                 switch (Console.ReadLine())
  28.                 {
  29.                     case "1":
  30.                         LaggTillDryck(antal_flaskor);
  31.                         antal_flaskor = antal_flaskor + 1;
  32.                         break;
  33.  
  34.  
  35.                     case "2":
  36.                         VisaInnehall();
  37.                         break;
  38.  
  39.                     case "3":
  40.                         BeraknaVarde();
  41.                         break;
  42.  
  43.                     case "4":
  44.                         lask = 0;
  45.                         break;
  46.  
  47.                 }
  48.             } while (lask != 0);
  49.            
  50.        }
  51.  
  52.         public void LaggTillDryck(int pos)
  53.         {
  54.             Console.WriteLine("Dryck");
  55.             Console.WriteLine("*    1 coca   ");
  56.             Console.WriteLine("*   2 Fanta    ");
  57.             Console.WriteLine("*  3 julmust   ");
  58.             Console.WriteLine("*     4 Sprite  ");
  59.             Console.WriteLine("*     5 Loka   ");
  60.  
  61.             sodacrate[pos] = Console.ReadLine();
  62.         }
  63.  
  64.         public void VisaInnehall()
  65.         {
  66.             for (int i = 0; i < 24; i++)
  67.             {
  68.                 Console.WriteLine(sodacrate[i]);
  69.             }
  70.         }
  71.  
  72.         public void BeraknaVarde()
  73.         {
  74.             Console.WriteLine(antal_flaskor);
  75.  
  76.         }
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement