Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MilitaryElite.Enums;
- using MilitaryElite.Exceptions;
- using System;
- using System.Text;
- // ReportLevel reportLevel = Enum.Parse<ReportLevel>(commandArguments[0], false);
- namespace MilitaryElite.Models
- {
- public class Mission : IMission
- {
- public Mission(string codeName, string state)
- {
- this.CodeName = codeName;
- this.State = this.TryParse(state);
- }
- public string CodeName { get; private set; }
- public State State { get; private set; }
- public void CompleteMission()
- {
- if(this.State == State.Finished)
- {
- throw new InvalidMissionCompletionException();
- }
- this.State = State.Finished;
- }
- private State TryParse(string stateStr)
- {
- bool parsed = Enum.TryParse(stateStr, out State state);
- if (!parsed)
- {
- throw new InvalidMissionStateException();
- }
- return state;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement