Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace II_5_gyak_1
- {
- public enum proci { AMD64, Iner64 }
- class Computer
- {
- protected int _memoria; // set, get
- public proci proc; // get
- protected int _mag; // get
- public bool irhato = false;
- public int memoria
- {
- set
- {
- if (value == 1 || value == 2 || value == 4 || value == 6 || value == 8 || value == 16)
- {
- _memoria = value;
- }
- else throw new Exception("memória error");
- }
- get
- {
- return _memoria;
- }
- }
- public int mag
- {
- set
- {
- if (irhato && (value == 1 || value == 2 || value == 4 || value == 8))
- {
- _mag = value;
- }
- else throw new Exception("mag error");
- }
- get
- {
- return _mag;
- }
- }
- public Computer(int pmem, int pmag, proci pproc)
- {
- memoria = pmem;
- mag = pmag;
- proc = pproc;
- }
- public Computer(int pmag, proci pproc) : this(8, pmag, pproc) { }
- public Computer() { }
- }
- class gameComputer : Computer
- {
- protected int _berletidij; // set, get
- protected int _oraszam;
- public bool szabade = true;
- public int berletidij
- {
- set
- {
- if (200 <= value && value <= 2000)
- {
- _berletidij = value;
- }
- else throw new Exception("díj error");
- }
- get
- {
- return _berletidij;
- }
- }
- //hány órát játszottak vele
- public int oraszam
- {
- set
- {
- if (0 < value && value < 12)
- {
- _oraszam = value;
- }
- else throw new Exception("óraszám error");
- }
- get
- {
- return _oraszam;
- }
- }
- // mennyi pént hozott
- protected int _kereset;
- public int kereset
- {
- set
- {
- // jajj anyám..
- }
- get
- {
- return _kereset;
- }
- }
- public gameComputer(int pdij, int pora, int pmem, int pmag, proci proc)
- : base(pmem, pmag, proc)
- {
- pdij = berletidij;
- pora = oraszam;
- pmag = mag;
- }
- }
- class gepterem
- {
- protected List<gameComputer> pclista = new List<gameComputer>();
- public void hozzaad(gameComputer x)
- {
- if (x != null)
- {
- pclista.Add(x);
- }
- }
- // gépválasztó fgv
- public void gepValaszto(int x)
- {
- if (pclista[x].szabade)
- {
- pclista[x].szabade = false;
- }
- else throw new Exception("már foglalt");
- }
- // gépelengedő fgv
- public void gepElengedo(gameComputer x)
- {
- x.szabade = true;
- }
- public int szabadGepekSzama()
- {
- int db = 0;
- foreach (var x in pclista)
- {
- if (x.szabade)
- {
- db++;
- }
- }
- return db;
- }
- }
- class seged //melyik gcomp, játék kezdete és vége KISZÁMÍTJA MENNYIT VOLT GÉPNÉL (datetime.now)
- {
- }
- class Program
- {
- static Random rand = new Random();
- static void Main(string[] args)
- {
- //feltöltés
- Computer comp = new Computer();
- gepterem terem = new gepterem();
- int[] mem = new int[] { 1, 2, 4, 6, 8, 12, 16 };
- int[] mag = new int[] { 1, 2, 4, 8 };
- int max = 10;
- comp.irhato = true;
- for (int i = 0; i < max; i++)
- {
- 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));
- terem.hozzaad(gcomp);
- }
- comp.irhato = false;
- List<int> valasztottak = new List<int>();
- while (true)
- {
- Console.WriteLine("1. Gépezés");
- Console.WriteLine("2. Záróra");
- int menü = int.Parse(Console.ReadLine());
- switch (menü)
- {
- case 1:
- Console.WriteLine("A 10 gépből {0} gép szabad, válassz egyet");
- int valaszt = int.Parse(Console.ReadLine());
- terem.gepValaszto(valaszt);
- valasztottak.Add(valaszt);
- break;
- case 2:
- int ossz = 0;
- foreach (int x in valasztottak)
- {
- // ossz +=
- }
- break;
- default:
- Console.WriteLine("Nincs ilyen opció!");
- break;
- }
- Console.ReadLine();
- Console.WriteLine();
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement