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;
- using System.Threading.Tasks;
- namespace CryptoMiningSystem
- {
- public class PCController
- {
- private static List<User> users = new List<User>();
- public decimal totalProfit = 0;
- public string RegisterUser(List<string> args)
- {
- if (users.Count() != 0)
- if (users.Count(x => x.Name == args[0]) != 0) return $"Username: { args[0]} already exists!";
- users.Add(new User(args[0], decimal.Parse(args[1])));
- return $"Successfully registered user - {args[0]}";
- }
- public string CreateComputer(List<string> args)
- {
- Processor processor;
- VideoCard videoCard;
- if (users.Count(x => x.Name == args[0]) == 0) return $"Username: {args[0]} does not exist!";
- User user = users.FirstOrDefault(x => x.Name == args[0]);
- if (args[1] == "Low") processor = new LowPerformanceProcessor(args[2], int.Parse(args[3]), decimal.Parse(args[4]));
- else if (args[2] == "High") processor = new HighPerformanceProcessor(args[2], int.Parse(args[3]), decimal.Parse(args[4]));
- else return "Invalid type processor!";
- if (args[5] == "Game") videoCard = new GameVideoCard(args[6], int.Parse(args[7]), int.Parse(args[8]), decimal.Parse(args[9]));
- else if (args[5] == "Mine") videoCard = new MineVideoCard(args[6], int.Parse(args[7]), int.Parse(args[8]), decimal.Parse(args[9]));
- else return "Invalid type video card!";
- if (user.Money < processor.Price + videoCard.Price) return $"User: {args[0]} - insufficient funds!";
- user.Computer = new Computer(processor, videoCard, int.Parse(args[10]));
- return $"Successfully created computer for user: {args[0]}!";
- /*
- name – символен низ
- processorType – символен низ
- processorModel – символен низ
- processorGeneration – цяло число
- processorPrice – реално число
- videoCardType – символен низ
- videoCardModel – символен низ
- videoCardGeneration – цяло число
- videoCardRam – цяло число
- videoCardPrice – реално число
- */
- }
- public string Mine()
- {
- decimal dailyProfit = 0;
- decimal userProfit = 0;
- foreach (var x in users)
- {
- {
- if (x.Computer != null)
- {
- userProfit += x.Computer.MinedAmountPerHour * 8;
- x.Computer.Processor.LifeWorkingHours -= 8;
- x.Computer.VideoCard.LifeWorkingHours -= 8;
- x.Money += userProfit; dailyProfit += userProfit;
- }
- }
- }
- //users.ForEach(x => { userProfit += x.Computer.MinedAmountPerHour * 8; x.Computer.Processor.LifeWorkingHours -= 8; x.Computer.VideoCard.LifeWorkingHours -= 8; x.Money += userProfit; dailyProfit += userProfit; });
- totalProfit += dailyProfit;
- return $"Daily profits: {dailyProfit}!";
- }
- public string UserInfo(List<string> args)
- {
- if (users.Count(x => x.Name == args[1]) == 0) return $"Username: {args[0]} does not exist!";
- User user = users.FirstOrDefault(x => x.Name == args[1]);
- StringBuilder sb = new StringBuilder();
- sb.AppendLine($"Name: { user.Name} - Stars: { user.Stars}\nBalance: { user.Money}");
- Computer computer = user.Computer;
- if (computer != null) sb.AppendLine($"PC Ram: {computer.Ram}\n - { computer.Processor.GetType().Name} – { computer.Processor.Model} – { computer.Processor.Generation}\n - { computer.VideoCard.GetType().Name} – { computer.VideoCard.Model} – { computer.VideoCard.Generation}\n *Video card Ram: { computer.VideoCard.Ram}\n");
- return sb.ToString();
- }
- public string Shutdown()
- {
- string result = "";
- users.OrderByDescending(x => x.Stars).ThenBy(x => x.Name).ToList().ForEach(x => result += UserInfo(new List<string>() { "UserInfo", $"{x.Name}" }) + "\n");
- result += $"System total profits: {(int)totalProfit}!!!";
- return result;
- }
- }
- }
- /*
- * namespace CryptoMiningSystem.Core
- {
- using Contracts;
- using CryptoMiningSystem.Entities;
- using CryptoMiningSystem.Entities.Components.Processors;
- using CryptoMiningSystem.Entities.Components.VideoCards;
- using CryptoMiningSystem.Factories;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System;
- //To do...
- public class PCController
- {
- List<User> users = new List<User>();
- public decimal totalProfit=0;
- public string RegisterUser(List<string> args)
- {
- if (users.Count(x => x.Name == args[0]) != 0) return $"Username: { args[0]} already exists!";
- users.Add(new User(args[0], decimal.Parse(args[1])));
- return $"Successfully registered user - {args[0]}";
- }
- public string CreateComputer(List<string> args)
- {
- Processor processor;
- VideoCard videoCard;
- if (users.Count(x => x.Name == args[1]) == 0) return $"Username: {args[0]} does not exist!";
- User user = users.FirstOrDefault(x => x.Name == args[1]);
- if (args[2] == "Low") processor = new LowPerformanceProcessor(args[3], int.Parse(args[4]), decimal.Parse(args[5]));
- else if (args[2] == "High") processor = new HighPerformanceProcessor(args[3], int.Parse(args[4]), decimal.Parse(args[5]));
- else return "Invalid type processor!";
- if (args[6] == "Game") videoCard = new GameVideoCard(args[7], int.Parse(args[8]), int.Parse(args[9]), decimal.Parse(args[10]));
- else if (args[6] == "Mine") videoCard = new MineVideoCard(args[7], int.Parse(args[8]), int.Parse(args[9]), decimal.Parse(args[10]));
- else return "Invalid type video card!";
- if (user.Money < processor.Price + videoCard.Price) return $"User: {args[0]} - insufficient funds!";
- user.Computer=new Computer(processor, videoCard, int.Parse(args[11]));
- return $"Successfully created computer for user: {args[1]}!";
- /*
- name – символен низ
- processorType – символен низ
- processorModel – символен низ
- processorGeneration – цяло число
- processorPrice – реално число
- videoCardType – символен низ
- videoCardModel – символен низ
- videoCardGeneration – цяло число
- videoCardRam – цяло число
- videoCardPrice – реално число
- }
- public string Mine()
- {
- decimal dailyProfit = 0;
- decimal userProfit = 0;
- users.ForEach(x => { userProfit += x.Computer.MinedAmountPerHour * 8; x.Computer.Processor.LifeWorkingHours -= 8; x.Computer.VideoCard.LifeWorkingHours -= 8; x.Money += userProfit; dailyProfit += userProfit; });
- totalProfit += dailyProfit;
- return $"Daily profits: {dailyProfit}!";
- }
- public string UserInfo(List<string> args)
- {
- if (users.Count(x => x.Name == args[1]) == 0) return $"Username: {args[0]} does not exist!";
- User user = users.FirstOrDefault(x => x.Name == args[1]);
- StringBuilder sb = new StringBuilder();
- sb.AppendLine($"Name: { user.Name} - Stars: { user.Stars}\nBalance: { user.Money}");
- Computer computer = user.Computer;
- if (computer != null) sb.AppendLine($"PC Ram: {computer.Ram}\n - { computer.Processor.GetType().Name} – { computer.Processor.Model} – { computer.Processor.Generation}\n - { computer.VideoCard.GetType().Name} – { computer.VideoCard.Model} – { computer.VideoCard.Generation}\n *Video card Ram: { computer.VideoCard.Ram}\n");
- return sb.ToString();
- }
- public string Shutdown()
- {
- string result = "";
- users.OrderByDescending(x => x.Stars).ThenBy(x => x.Name).ToList().ForEach(x => result += UserInfo(new List<string>() { "UserInfo", $"{x.Name}" }) + "\n");
- result += $"System total profits: {(int)totalProfit}!!!";
- return result;
- }
- }
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement