public void Print(int pages) { var InkNeededForPage = new Random(); Console.WriteLine("Printing: "); //PaperCount -= Math.Min(PaperCount, pages); if (PaperCount - pages < 0) { OutOfPaperEvent.Invoke(this, EventArgs.Empty); return; } PaperCount -= pages; Console.WriteLine(""); for (int pageNo = 0; pageNo < pages; pageNo++) { foreach (var ink in Inks) { ink.InkLeft -= Math.Min(ink.InkLeft, InkNeededForPage.Next(0, 5)); if (ink.InkLeft == 0) { OutOfInkEvent.Invoke(this, new OutOfInkEventArgs(ink.Colour, pageNo)); return; } } } PrintCompleteEvent.Invoke(this, EventArgs.Empty); }
public void Print(int pageNumber) { if (_paperCount == 0) { OutOfPaperEvent?.Invoke(this, new OutOfPaperEventArgs(pageNumber)); return; } else { foreach (var toner in _Toners) { if (toner.Level <= 0) { OutOfTonerEvent.Invoke(this, new OutOfTonerEventArgs(toner.Color)); return; } } Console.WriteLine("Printing"); --_paperCount; foreach (var toner in _Toners) { toner.Level -= _random.NextDouble(); } } }
public void Print() { bool noInk = false; foreach (var color in ink) { if (color.inkAmount <= 0) { noInk = true; OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs(color.inkName)); } } if (!noInk) { if (paperAmount <= 0) { OutOfPaperEvent?.Invoke(this, EventArgs.Empty); } else { Console.WriteLine("Printing"); paperAmount--; ink.ForEach(x => x.inkAmount -= _random.Next()); } } }
public void print(int paperCount, int cyanQuality, int magnetaQuality, int yellowQuality, int blackQuality) { Console.WriteLine("Printing start"); for (int i = 1; i <= paperCount; i++) { if (PaperCount <= 0) { OutOfPaperEvent?.Invoke(this, EventArgs.Empty); break; } if (CyanInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArks("Cyan")); break; } if (MagentaInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArks("Magenta")); break; } if (YellowInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArks("Yellow")); break; } if (BlackInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArks("Black")); break; } PaperCount--; CyanInk -= cyanQuality; MagentaInk -= magnetaQuality; YellowInk -= yellowQuality; BlackInk -= blackQuality; Console.WriteLine("Kartka " + i + " wydrukowana"); } }
public void Print(int pages, int cyan, int magneta, int yellow, int black) { Console.WriteLine("Printing..."); for (int i = 1; i <= pages; i++) { if (_paperCount <= 0) { OutOfPaperEvent?.Invoke(this, EventArgs.Empty); return; } if (_cyanInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs("Cyan")); break; } if (_magentaInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs("Magenta")); break; } if (_yellowInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs("Yellow")); break; } if (_blackInk <= 0) { OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs("Black")); break; } _paperCount--; _printedPages++; _cyanInk -= cyan; _magentaInk -= magneta; _yellowInk -= yellow; _blackInk -= black; } Console.WriteLine($"Number of printed pages: {_printedPages}"); }
public void Print(int pages) { Console.WriteLine("Printing..."); if (PaperCount - pages < 0) { OutOfPaperEvent.Invoke(this, EventArgs.Empty); return; } PaperCount -= pages; Console.WriteLine(""); for (int pageNumber = 0; pageNumber < pages; pageNumber++) { foreach (var item in Inks) { item.InkLeft -= Math.Min(item.InkLeft, random.Next(0, 10)); if (item.InkLeft == 0) { OutOfInkEvent.Invoke(this, new OutOfInkEventArgs(item.Colour, pageNumber)); return; } } } }
//private Random a; public void Print(int PNumber) { if (_paperCount == 0) { OutOfPaperEvent?.Invoke(this, new OutOfPaperEventArgs(PNumber)); return; } else { foreach (var ink in _inks) { if (ink.Level <= 0) { OutOfInkEvent.Invoke(this, new OutOfInkEventArgs(ink.Color)); } } Console.WriteLine("Printing..."); --_paperCount; foreach (var ink in _inks) { ink.Level -= a.Next(10); } } /* if (_inkCount < 0) * { * OutOfInkEvent?.Invoke(this, new OutOfInkEventArgs()); * return; * * } * else * { * _inkCount -= a.Next(10); * }*/ }