Advertisement
csaki

II_5 proggyak

Mar 5th, 2013
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace II_5_gyak_1
  7. {
  8.     public enum proci { AMD64, Iner64 }
  9.  
  10.  
  11.     class Computer
  12.     {
  13.         protected int _memoria; // set, get
  14.         public proci proc; // get
  15.         protected int _mag; // get
  16.         public bool irhato = false;
  17.  
  18.         public int memoria
  19.         {
  20.             set
  21.             {
  22.                 if (value == 1 || value == 2 || value == 4 || value == 6 || value == 8 || value == 16)
  23.                 {
  24.                     _memoria = value;
  25.                 }
  26.                 else throw new Exception("memória error");
  27.             }
  28.             get
  29.             {
  30.                 return _memoria;
  31.             }
  32.         }
  33.  
  34.         public int mag
  35.         {
  36.             set
  37.             {
  38.                 if (irhato && (value == 1 || value == 2 || value == 4 || value == 8))
  39.                 {
  40.                     _mag = value;
  41.                 }
  42.                 else throw new Exception("mag error");
  43.             }
  44.             get
  45.             {
  46.                 return _mag;
  47.             }
  48.         }
  49.  
  50.         public Computer(int pmem, int pmag, proci pproc)
  51.         {
  52.             memoria = pmem;
  53.             mag = pmag;
  54.             proc = pproc;
  55.         }
  56.  
  57.         public Computer(int pmag, proci pproc) : this(8, pmag, pproc) { }
  58.  
  59.         public Computer() { }
  60.  
  61.     }
  62.  
  63.     class gameComputer : Computer
  64.     {
  65.         protected int _berletidij; // set, get
  66.         protected int _oraszam;
  67.         public bool szabade = true;
  68.  
  69.         public int berletidij
  70.         {
  71.             set
  72.             {
  73.                 if (200 <= value && value <= 2000)
  74.                 {
  75.                     _berletidij = value;
  76.                 }
  77.                 else throw new Exception("díj error");
  78.             }
  79.             get
  80.             {
  81.                 return _berletidij;
  82.             }
  83.         }
  84.  
  85.         //hány órát játszottak vele
  86.  
  87.         public int oraszam
  88.         {
  89.             set
  90.             {
  91.                 if (0 < value && value < 12)
  92.                 {
  93.                     _oraszam = value;
  94.                 }
  95.                 else throw new Exception("óraszám error");
  96.             }
  97.             get
  98.             {
  99.                 return _oraszam;
  100.             }
  101.         }
  102.  
  103.         // mennyi pént hozott
  104.  
  105.         protected int _kereset;
  106.  
  107.         public int kereset
  108.         {
  109.             set
  110.             {
  111.                 // jajj anyám..
  112.             }
  113.  
  114.             get
  115.             {
  116.                 return _kereset;
  117.             }
  118.         }
  119.  
  120.         public gameComputer(int pdij, int pora, int pmem, int pmag, proci proc)
  121.             : base(pmem, pmag, proc)
  122.         {
  123.             pdij = berletidij;
  124.             pora = oraszam;
  125.             pmag = mag;
  126.         }
  127.     }
  128.  
  129.     class gepterem
  130.     {
  131.         protected List<gameComputer> pclista = new List<gameComputer>();
  132.  
  133.         public void hozzaad(gameComputer x)
  134.         {
  135.             if (x != null)
  136.             {
  137.                 pclista.Add(x);
  138.             }
  139.         }
  140.  
  141.         // gépválasztó fgv
  142.         public void gepValaszto(int x)
  143.         {
  144.             if (pclista[x].szabade)
  145.             {
  146.                 pclista[x].szabade = false;
  147.             }
  148.             else throw new Exception("már foglalt");
  149.         }
  150.  
  151.         // gépelengedő fgv
  152.         public void gepElengedo(gameComputer x)
  153.         {
  154.             x.szabade = true;
  155.         }
  156.  
  157.         public int szabadGepekSzama()
  158.         {
  159.             int db = 0;
  160.             foreach (var x in pclista)
  161.             {
  162.                 if (x.szabade)
  163.                 {
  164.                     db++;
  165.                 }
  166.             }
  167.             return db;
  168.         }
  169.     }
  170.  
  171.     class seged //melyik gcomp, játék kezdete és vége  KISZÁMÍTJA MENNYIT VOLT GÉPNÉL  (datetime.now)
  172.     {
  173.  
  174.     }
  175.  
  176.     class Program
  177.     {
  178.         static Random rand = new Random();
  179.  
  180.         static void Main(string[] args)
  181.         {
  182.             //feltöltés
  183.             Computer comp = new Computer();
  184.             gepterem terem = new gepterem();
  185.             int[] mem = new int[] { 1, 2, 4, 6, 8, 12, 16 };
  186.             int[] mag = new int[] { 1, 2, 4, 8 };
  187.             int max = 10;
  188.             comp.irhato = true;
  189.             for (int i = 0; i < max; i++)
  190.             {
  191.                 gameComputer gcomp = new gameComputer(rand.Next(2, 20) * 100, rand.Next(1,12), mem[rand.Next(7)], mag[rand.Next(4)], (proci)rand.Next(2));
  192.                 terem.hozzaad(gcomp);                
  193.             }
  194.             comp.irhato = false;
  195.  
  196.             List<int> valasztottak = new List<int>();
  197.             while (true)
  198.             {
  199.                 Console.WriteLine("1. Gépezés");
  200.                 Console.WriteLine("2. Záróra");
  201.  
  202.                 int menü = int.Parse(Console.ReadLine());
  203.                
  204.                 switch (menü)
  205.                 {
  206.                     case 1:
  207.                         Console.WriteLine("A 10 gépből {0} gép szabad, válassz egyet");
  208.                         int valaszt = int.Parse(Console.ReadLine());
  209.                         terem.gepValaszto(valaszt);
  210.                         valasztottak.Add(valaszt);
  211.                         break;
  212.  
  213.                     case 2:
  214.                         int ossz = 0;
  215.                         foreach (int x in valasztottak)
  216.                         {
  217.                             // ossz +=
  218.                         }
  219.                         break;
  220.  
  221.                     default:
  222.                         Console.WriteLine("Nincs ilyen opció!");
  223.                         break;
  224.                 }
  225.                 Console.ReadLine();
  226.                 Console.WriteLine();
  227.                 Console.WriteLine();
  228.             }
  229.            
  230.            
  231.         }
  232.     }
  233. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement