SHARE
TWEET

Untitled

a guest Oct 20th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using CryptoMiningSystem.Entities.Components.Contracts;
  2. using CryptoMiningSystem.Entities.Contracts;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using CryptoMiningSystem.Entities.Contracts;
  7. using CryptoMiningSystem.Utilities;
  8.  
  9.  
  10. namespace CryptoMiningSystem.Entities.Contracts
  11. {
  12.     public class User : IUser
  13.     {
  14.         public User(string name,decimal money,int stars,Computer computer)
  15.         {
  16.             this.Name = name;
  17.             this.Money = money;
  18.             this.Stars = stars;
  19.             this.Computer = computer;
  20.         }
  21.         private string name;
  22.         private decimal money;
  23.         public string Name
  24.         {
  25.             get { return this.name; }
  26.             private set
  27.             {
  28.                 if (string.IsNullOrWhiteSpace(value))
  29.                 {
  30.                     throw new ArgumentException("Username must not be null or empty!");
  31.                 }
  32.                 this.name = value;
  33.             }
  34.         }
  35.  
  36.         private int stars;
  37.         public int Stars
  38.         {
  39.             get { return this.stars=(int)money / 100; }
  40.             private set { this.stars = value; }
  41.         }
  42.         public decimal Money
  43.         {
  44.             get { return this.money; }
  45.             private set
  46.             {
  47.                 if (value<0)
  48.                 {
  49.                     throw new ArgumentException("User's money cannot be less than 0!");
  50.                 }
  51.                 this.money = value;
  52.             }
  53.         }
  54.  
  55.         public Computer Computer { get; private set; }
  56.     }
  57. }
  58.  
  59.  
  60.  
  61.  
  62. using System;
  63. using System.Collections.Generic;
  64. using System.Text;
  65. using CryptoMiningSystem.Entities.Components.Contracts;
  66. using CryptoMiningSystem.Entities.Components.VideoCards;
  67. namespace CryptoMiningSystem.Entities.Contracts
  68. {
  69.     public class Computer : IComputer
  70.     {
  71.         public Computer(Processor processor,VideoCard videoCard,
  72.             int Ram, decimal  minedAmountPerHour)
  73.         {
  74.             this.Processor = processor;
  75.             this.VideoCard = videoCard;
  76.             this.Ram = ram;
  77.             this.MinedAmountPerHour = minedAmountPerHour;
  78.         }
  79.         public Processor Processor { get; private set; }
  80.  
  81.         public VideoCard VideoCard { get; private set; }
  82.  
  83.         private int ram;
  84.         public int Ram
  85.         {
  86.             get { return this.ram; }
  87.             private set
  88.             {
  89.                 if (value<=0 || value>32)
  90.                 {
  91.                     throw new ArgumentException("PC Ram cannot be less or equal to 0 and more than 32!");
  92.                 }
  93.                 this.ram = value;
  94.             }
  95.         }
  96.  
  97.         private decimal minedAmountPerHour;
  98.         public decimal MinedAmountPerHour// =>VideoCard.MinedMoneyPerHour * Processor.MineMultiplier;
  99.         {
  100.             get
  101.             {
  102.              return this.minedAmountPerHour=
  103.              VideoCard.MinedMoneyPerHour * Processor.MineMultiplier;
  104.             }
  105.             private set
  106.             {
  107.                 this.minedAmountPerHour = value;
  108.             }
  109.         }
  110.            
  111.     }
  112. }
  113.  
  114.  
  115.  
  116.  
  117.  
  118. using System;
  119. using System.Collections.Generic;
  120. using System.ComponentModel;
  121. using static System.ComponentModel.IComponent;
  122. using System.Text;
  123. using CryptoMiningSystem.Entities.Components.Contracts;
  124. namespace CryptoMiningSystem.Entities.Components
  125. {
  126.     public class Component : IComponent
  127.     {
  128.         public Component(string model,decimal price,int generation,
  129.             int lifeWorkingHours)
  130.         {
  131.             this.Model = model;
  132.             this.Price = price;
  133.             this.Generation = generation;
  134.             this.LifeWorkingHours = lifeWorkingHours;
  135.         }
  136.         private string model;
  137.         private decimal price;
  138.         public string Model
  139.         {
  140.             get { return this.model; }
  141.             private set
  142.             {
  143.                 if (string.IsNullOrWhiteSpace(value))
  144.                 {
  145.                     throw new ArgumentException("Model cannot be null or empty!");
  146.                 }
  147.                 this.model = value;
  148.             }
  149.         }
  150.  
  151.         public decimal Price
  152.         {
  153.             get { return this.price; }
  154.             private set
  155.             {
  156.                 if (value<=0||value>10000)
  157.                 {
  158.                     throw new ArgumentException("Price cannot be less or equal to 0 and more than 10000!");
  159.                 }
  160.                 this.price = value;
  161.             }
  162.         }
  163.  
  164.         private int generation;
  165.         public int Generation
  166.         {
  167.             get { return this.generation=1; }
  168.             private set
  169.             {
  170.                 if (value<=0)
  171.                 {
  172.                     throw new ArgumentException("Generation cannot be 0 or negative!");
  173.                 }
  174.                 this.generation = value;
  175.             }
  176.         }
  177.  
  178.         public int LifeWorkingHours { get; private set; }
  179.     }
  180. }
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188. using CryptoMiningSystem.Entities.Components.Processors.Contracts;
  189. using System;
  190. using System.Collections.Generic;
  191. using System.Text;
  192.  
  193. namespace CryptoMiningSystem
  194. {
  195.     public abstract class Processor : IProcessor
  196.     {//
  197.         private int mineMultiplier;
  198.         private int generationProcessor;
  199.         //public Processor(string model, decimal price, int generationProcessor,
  200.         //    int lifeWorkingHours) :
  201.         //    base(model, price, generationProcessor, lifeWorkingHours)
  202.         //{
  203.         //    this.GenerationProcessor = generationProcessor;
  204.         //}
  205.         protected Processor(int mineMultiplier)
  206.         {
  207.             this.MineMultiplier = mineMultiplier;
  208.         }
  209.  
  210.  
  211.         //public Processor(int mineMultiplier)
  212.         //{
  213.         //    this.MineMultiplier = mineMultiplier;
  214.         //}
  215.         public int GenerationProcessor
  216.         {
  217.             get { return this.generationProcessor; }
  218.             private set
  219.             {
  220.                 if (value>9)
  221.                 {
  222.                     throw new ArgumentException($"" +
  223.                $"{this.GetType().Name} generation cannot be more than 9!");
  224.                 }
  225.                 this.generationProcessor = value;
  226.             }
  227.         }
  228.        
  229.  
  230.         public int MineMultiplier
  231.         {
  232.             get { return this.mineMultiplier; }
  233.             private set
  234.             {
  235.                 this.mineMultiplier = value;
  236.             }
  237.         }
  238.         //public void LowPerformanceProcessor()
  239.         //{
  240.         //    this.MineMultiplier = 2;
  241.         //}
  242.         //public void HighPerformanceProcessor()
  243.         //{
  244.         //    MineMultiplier = 8;
  245.         //}
  246.     }
  247. }
  248.  
  249.  
  250.  
  251.  
  252. using CryptoMiningSystem.Entities.Components.Contracts;
  253. using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
  254. using System;
  255. using System.Collections.Generic;
  256. using System.ComponentModel;
  257. using System.Text;
  258. using CryptoMiningSystem.Entities.Components.Contracts;
  259. namespace CryptoMiningSystem
  260. {
  261.     public class VideoCard : Entities.Components.Contracts.Component ,IVideoCard
  262.     {
  263.         public decimal MinedMoneyPerHour =>
  264.             (ram * base.Generation) / 10;
  265.  
  266.         private int lifeWorkingHoursCost;
  267.         public int LifeWorkingHoursCost //=> ram * base.Generation * 10;
  268.         {
  269.             get { return lifeWorkingHoursCost; }
  270.             private set
  271.             {
  272.                 this.lifeWorkingHoursCost = value;
  273.             }
  274.         }
  275.         private int ram;
  276.  
  277.         public VideoCard(string model, decimal price, int generation,
  278.             int lifeWorkingHoursCost) :
  279.             base(model, price, generation, lifeWorkingHoursCost)
  280.         {
  281.             this.lifeWorkingHoursCost = lifeWorkingHoursCost;
  282.         }
  283.  
  284.         //public VideoCard(string model, decimal price, int generation
  285.         //    ) :
  286.         //    base(model, price, generation, LifeWorkingHoursCost)
  287.         //{
  288.         //    this.LifeWorkingHoursCost = lifeWorkingHours;
  289.         //}
  290.  
  291.         public int Ram
  292.         {
  293.             get { return this.ram; }
  294.             private set
  295.             {
  296.                 if (value<=0 || value>32)
  297.                 {
  298.                     throw new ArgumentException($"{this.GetType().Name} ram cannot less or equal to 0 and more than 32!");
  299.                 }
  300.                 this.ram = value;
  301.             }
  302.         }
  303.     }
  304. }
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311. using System;
  312. using System.Collections.Generic;
  313. using System.Text;
  314.  
  315. namespace CryptoMiningSystem.Entities.Components.Processors
  316. {
  317.     public class LowPerformanceProcessor : Processor
  318.     {
  319.         private const int MineMultiplierConst = 2;
  320.         public LowPerformanceProcessor()
  321.             : base(MineMultiplierConst)
  322.         {
  323.         }
  324.     }
  325. }
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. using System;
  333. using System.Collections.Generic;
  334. using System.Text;
  335.  
  336. namespace CryptoMiningSystem.Entities.Components.Processors
  337. {
  338.     public class HighPerformanceProcessor :Processor//, IComponent
  339.     {
  340.         private const int mineMultiplierConst = 8;
  341.  
  342.      //   public int MineMultiplier => mineMultiplierConst;
  343.  
  344.         //public HighPerformanceProcessor(string model, decimal price,
  345.         //    int generation, int lifeWorkingHours) :
  346.         //    base(model, price, generation, lifeWorkingHours)
  347.         //{
  348.         //}
  349.         public HighPerformanceProcessor()
  350.             : base(mineMultiplierConst)
  351.         {
  352.         }
  353.     }
  354. }
  355.  
  356.  
  357.  
  358.  
  359. using CryptoMiningSystem.Entities.Components.Contracts;
  360. using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
  361. using System;
  362. using System.Collections.Generic;
  363. using System.Text;
  364. using CryptoMiningSystem.Entities.Contracts;
  365. using CryptoMiningSystem.Entities.Components;
  366.  
  367. namespace CryptoMiningSystem.CryptoMiningSystem.Entities.Contracts
  368. {
  369.     public class MineVideoCard : Component, IVideoCard
  370.     {
  371.         private int generationConst;
  372.  
  373.         public int GenerationConst
  374.         {
  375.             get { return this.generationConst; }
  376.             private set
  377.             {
  378.                 if (value>6)
  379.                 {
  380.                     throw new ArgumentException("Mine video card generation cannot be more than 6!");
  381.                 }
  382.                 this.generationConst = value;
  383.             }
  384.         }
  385.         public MineVideoCard(string model, decimal price, int generation,
  386.             int lifeWorkingHours) :
  387.             base(model, price, generation, lifeWorkingHours)
  388.         {
  389.             this.GenerationConst = generation;
  390.         }
  391.  
  392.         public decimal MinedMoneyPerHour => throw new NotImplementedException();
  393.  
  394.         public int Ram => throw new NotImplementedException();
  395.     }
  396. }
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405. using CryptoMiningSystem.Entities.Components.Contracts;
  406. using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
  407. using System;
  408. using System.Collections.Generic;
  409. using System.Text;
  410. using CryptoMiningSystem.Entities.Components;
  411. namespace CryptoMiningSystem.Entities.Contracts
  412. {
  413.     public class GameVideoCard : Component, IVideoCard
  414.     {
  415.         private int generationConst;
  416.  
  417.         public int GenerationConst
  418.         {
  419.             get { return generationConst; }
  420.             private set
  421.             {
  422.                 if (value>0)
  423.                 {
  424.                     throw new ArgumentException("Game video card generation cannot be more than 9!");
  425.                 }
  426.                 generationConst = value;
  427.             }
  428.         }
  429.  
  430.         public GameVideoCard(string model, decimal price,  int GenerationConst,
  431.             int lifeWorkingHours) : base(model, price, GenerationConst, lifeWorkingHours)
  432.         {
  433.             this.GenerationConst = generationConst;
  434.         }
  435.  
  436.         public decimal MinedMoneyPerHour => throw new NotImplementedException();
  437.  
  438.         public int Ram => throw new NotImplementedException();
  439.     }
  440. }
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447. namespace CryptoMiningSystem.Entities.Components.Contracts
  448. {
  449.     public interface IComponent
  450.     {
  451.         string Model { get; }
  452.  
  453.         decimal Price { get; }
  454.  
  455.         int Generation { get; }
  456.  
  457.         int LifeWorkingHours { get; }
  458.     }
  459. }
  460.  
  461.  
  462.  
  463.  
  464. namespace CryptoMiningSystem.Entities.Components.Processors.Contracts
  465. {
  466.     public interface IProcessor
  467.     {
  468.         int MineMultiplier { get; }
  469.     }
  470. }
  471.  
  472.  
  473.  
  474.  
  475. namespace CryptoMiningSystem.Entities.Components.VideoCards.Contracts
  476. {
  477.     public interface IVideoCard
  478.     {
  479.         decimal MinedMoneyPerHour { get; }
  480.  
  481.         int Ram { get; }
  482.     }
  483. }
  484.  
  485.  
  486.  
  487. using CryptoMiningSystem.Entities.Components.Processors;
  488. using CryptoMiningSystem.Entities.Components.VideoCards;
  489.  
  490. namespace CryptoMiningSystem.Entities.Contracts
  491. {
  492.     public interface IComputer
  493.     {
  494.         Processor Processor { get; }
  495.  
  496.         VideoCard VideoCard { get; }
  497.  
  498.         int Ram { get; }
  499.  
  500.         decimal MinedAmountPerHour { get; }
  501.     }
  502. }
  503.  
  504.  
  505.  
  506.  
  507.  
  508. using CryptoMiningSystem.Entities.Components.Contracts;
  509. using System;
  510. using System.Collections.Generic;
  511. using System.Text;
  512. using CryptoMiningSystem.Entities.Components.VideoCards;
  513. namespace CryptoMiningSystem.Entities.Contracts
  514. {
  515.     public interface IUser
  516.     {
  517.         string Name { get; }
  518.  
  519.         int Stars{ get; }
  520.  
  521.         decimal Money { get; }
  522.  
  523.         Computer Computer { get; }
  524.     }
  525. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top