Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MortalEngines.Entities.Contracts;
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace MortalEngines.Entities
- {
- public class Pilot : IPilot
- {
- private string name;
- private IList<IMachine> machines;
- public Pilot(string name)
- {
- this.Name = name;
- this.machines = new List<IMachine>();
- }
- public string Name
- {
- get
- {
- return this.name;
- }
- private set
- {
- if (string.IsNullOrWhiteSpace(value))
- {
- throw new ArgumentNullException("Pilot name cannot be null or empty string.");
- }
- this.name = value;
- }
- }
- public void AddMachine(IMachine machine)
- {
- if (machine == null)
- {
- throw new NullReferenceException("Null machine cannot be added to the pilot.");
- }
- this.machines.Add(machine);
- }
- public string Report()
- {
- StringBuilder sb = new StringBuilder();
- sb.AppendLine($"{this.Name} - {this.machines.Count} machines");
- foreach (IMachine machine in this.machines)
- {
- sb.AppendLine(machine.ToString());
- }
- return sb.ToString().TrimEnd();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement