Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using CryptoMiningSystem.Entities.Components.Contracts;
- using CryptoMiningSystem.Entities.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CryptoMiningSystem.Entities.Contracts;
- using CryptoMiningSystem.Utilities;
- namespace CryptoMiningSystem.Entities.Contracts
- {
- public class User : IUser
- {
- public User(string name,decimal money,int stars,Computer computer)
- {
- this.Name = name;
- this.Money = money;
- this.Stars = stars;
- this.Computer = computer;
- }
- private string name;
- private decimal money;
- public string Name
- {
- get { return this.name; }
- private set
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("Username must not be null or empty!");
- }
- this.name = value;
- }
- }
- private int stars;
- public int Stars
- {
- get { return this.stars=(int)money / 100; }
- private set { this.stars = value; }
- }
- public decimal Money
- {
- get { return this.money; }
- private set
- {
- if (value<0)
- {
- throw new ArgumentException("User's money cannot be less than 0!");
- }
- this.money = value;
- }
- }
- public Computer Computer { get; private set; }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CryptoMiningSystem.Entities.Components.Contracts;
- using CryptoMiningSystem.Entities.Components.VideoCards;
- namespace CryptoMiningSystem.Entities.Contracts
- {
- public class Computer : IComputer
- {
- public Computer(Processor processor,VideoCard videoCard,
- int Ram, decimal minedAmountPerHour)
- {
- this.Processor = processor;
- this.VideoCard = videoCard;
- this.Ram = ram;
- this.MinedAmountPerHour = minedAmountPerHour;
- }
- public Processor Processor { get; private set; }
- public VideoCard VideoCard { get; private set; }
- private int ram;
- public int Ram
- {
- get { return this.ram; }
- private set
- {
- if (value<=0 || value>32)
- {
- throw new ArgumentException("PC Ram cannot be less or equal to 0 and more than 32!");
- }
- this.ram = value;
- }
- }
- private decimal minedAmountPerHour;
- public decimal MinedAmountPerHour// =>VideoCard.MinedMoneyPerHour * Processor.MineMultiplier;
- {
- get
- {
- return this.minedAmountPerHour=
- VideoCard.MinedMoneyPerHour * Processor.MineMultiplier;
- }
- private set
- {
- this.minedAmountPerHour = value;
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using static System.ComponentModel.IComponent;
- using System.Text;
- using CryptoMiningSystem.Entities.Components.Contracts;
- namespace CryptoMiningSystem.Entities.Components
- {
- public class Component : IComponent
- {
- public Component(string model,decimal price,int generation,
- int lifeWorkingHours)
- {
- this.Model = model;
- this.Price = price;
- this.Generation = generation;
- this.LifeWorkingHours = lifeWorkingHours;
- }
- private string model;
- private decimal price;
- public string Model
- {
- get { return this.model; }
- private set
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentException("Model cannot be null or empty!");
- }
- this.model = value;
- }
- }
- public decimal Price
- {
- get { return this.price; }
- private set
- {
- if (value<=0||value>10000)
- {
- throw new ArgumentException("Price cannot be less or equal to 0 and more than 10000!");
- }
- this.price = value;
- }
- }
- private int generation;
- public int Generation
- {
- get { return this.generation=1; }
- private set
- {
- if (value<=0)
- {
- throw new ArgumentException("Generation cannot be 0 or negative!");
- }
- this.generation = value;
- }
- }
- public int LifeWorkingHours { get; private set; }
- }
- }
- using CryptoMiningSystem.Entities.Components.Processors.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace CryptoMiningSystem
- {
- public abstract class Processor : IProcessor
- {//
- private int mineMultiplier;
- private int generationProcessor;
- //public Processor(string model, decimal price, int generationProcessor,
- // int lifeWorkingHours) :
- // base(model, price, generationProcessor, lifeWorkingHours)
- //{
- // this.GenerationProcessor = generationProcessor;
- //}
- protected Processor(int mineMultiplier)
- {
- this.MineMultiplier = mineMultiplier;
- }
- //public Processor(int mineMultiplier)
- //{
- // this.MineMultiplier = mineMultiplier;
- //}
- public int GenerationProcessor
- {
- get { return this.generationProcessor; }
- private set
- {
- if (value>9)
- {
- throw new ArgumentException($"" +
- $"{this.GetType().Name} generation cannot be more than 9!");
- }
- this.generationProcessor = value;
- }
- }
- public int MineMultiplier
- {
- get { return this.mineMultiplier; }
- private set
- {
- this.mineMultiplier = value;
- }
- }
- //public void LowPerformanceProcessor()
- //{
- // this.MineMultiplier = 2;
- //}
- //public void HighPerformanceProcessor()
- //{
- // MineMultiplier = 8;
- //}
- }
- }
- using CryptoMiningSystem.Entities.Components.Contracts;
- using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Text;
- using CryptoMiningSystem.Entities.Components.Contracts;
- namespace CryptoMiningSystem
- {
- public class VideoCard : Entities.Components.Contracts.Component ,IVideoCard
- {
- public decimal MinedMoneyPerHour =>
- (ram * base.Generation) / 10;
- private int lifeWorkingHoursCost;
- public int LifeWorkingHoursCost //=> ram * base.Generation * 10;
- {
- get { return lifeWorkingHoursCost; }
- private set
- {
- this.lifeWorkingHoursCost = value;
- }
- }
- private int ram;
- public VideoCard(string model, decimal price, int generation,
- int lifeWorkingHoursCost) :
- base(model, price, generation, lifeWorkingHoursCost)
- {
- this.lifeWorkingHoursCost = lifeWorkingHoursCost;
- }
- //public VideoCard(string model, decimal price, int generation
- // ) :
- // base(model, price, generation, LifeWorkingHoursCost)
- //{
- // this.LifeWorkingHoursCost = lifeWorkingHours;
- //}
- public int Ram
- {
- get { return this.ram; }
- private set
- {
- if (value<=0 || value>32)
- {
- throw new ArgumentException($"{this.GetType().Name} ram cannot less or equal to 0 and more than 32!");
- }
- this.ram = value;
- }
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace CryptoMiningSystem.Entities.Components.Processors
- {
- public class LowPerformanceProcessor : Processor
- {
- private const int MineMultiplierConst = 2;
- public LowPerformanceProcessor()
- : base(MineMultiplierConst)
- {
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace CryptoMiningSystem.Entities.Components.Processors
- {
- public class HighPerformanceProcessor :Processor//, IComponent
- {
- private const int mineMultiplierConst = 8;
- // public int MineMultiplier => mineMultiplierConst;
- //public HighPerformanceProcessor(string model, decimal price,
- // int generation, int lifeWorkingHours) :
- // base(model, price, generation, lifeWorkingHours)
- //{
- //}
- public HighPerformanceProcessor()
- : base(mineMultiplierConst)
- {
- }
- }
- }
- using CryptoMiningSystem.Entities.Components.Contracts;
- using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CryptoMiningSystem.Entities.Contracts;
- using CryptoMiningSystem.Entities.Components;
- namespace CryptoMiningSystem.CryptoMiningSystem.Entities.Contracts
- {
- public class MineVideoCard : Component, IVideoCard
- {
- private int generationConst;
- public int GenerationConst
- {
- get { return this.generationConst; }
- private set
- {
- if (value>6)
- {
- throw new ArgumentException("Mine video card generation cannot be more than 6!");
- }
- this.generationConst = value;
- }
- }
- public MineVideoCard(string model, decimal price, int generation,
- int lifeWorkingHours) :
- base(model, price, generation, lifeWorkingHours)
- {
- this.GenerationConst = generation;
- }
- public decimal MinedMoneyPerHour => throw new NotImplementedException();
- public int Ram => throw new NotImplementedException();
- }
- }
- using CryptoMiningSystem.Entities.Components.Contracts;
- using CryptoMiningSystem.Entities.Components.VideoCards.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CryptoMiningSystem.Entities.Components;
- namespace CryptoMiningSystem.Entities.Contracts
- {
- public class GameVideoCard : Component, IVideoCard
- {
- private int generationConst;
- public int GenerationConst
- {
- get { return generationConst; }
- private set
- {
- if (value>0)
- {
- throw new ArgumentException("Game video card generation cannot be more than 9!");
- }
- generationConst = value;
- }
- }
- public GameVideoCard(string model, decimal price, int GenerationConst,
- int lifeWorkingHours) : base(model, price, GenerationConst, lifeWorkingHours)
- {
- this.GenerationConst = generationConst;
- }
- public decimal MinedMoneyPerHour => throw new NotImplementedException();
- public int Ram => throw new NotImplementedException();
- }
- }
- namespace CryptoMiningSystem.Entities.Components.Contracts
- {
- public interface IComponent
- {
- string Model { get; }
- decimal Price { get; }
- int Generation { get; }
- int LifeWorkingHours { get; }
- }
- }
- namespace CryptoMiningSystem.Entities.Components.Processors.Contracts
- {
- public interface IProcessor
- {
- int MineMultiplier { get; }
- }
- }
- namespace CryptoMiningSystem.Entities.Components.VideoCards.Contracts
- {
- public interface IVideoCard
- {
- decimal MinedMoneyPerHour { get; }
- int Ram { get; }
- }
- }
- using CryptoMiningSystem.Entities.Components.Processors;
- using CryptoMiningSystem.Entities.Components.VideoCards;
- namespace CryptoMiningSystem.Entities.Contracts
- {
- public interface IComputer
- {
- Processor Processor { get; }
- VideoCard VideoCard { get; }
- int Ram { get; }
- decimal MinedAmountPerHour { get; }
- }
- }
- using CryptoMiningSystem.Entities.Components.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CryptoMiningSystem.Entities.Components.VideoCards;
- namespace CryptoMiningSystem.Entities.Contracts
- {
- public interface IUser
- {
- string Name { get; }
- int Stars{ get; }
- decimal Money { get; }
- Computer Computer { get; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement