internal void Run() { consoleSegment = ConsoleSegment.Main; bool inputComplete; do { inputComplete = InputComplete(); }while (!inputComplete); }
private bool AwardRemoving() { consoleSegment = ConsoleSegment.Award; Console.Clear(); Console.WriteLine("Choose award by number:"); Console.WriteLine("----------------------"); new OutputPl()?.RemoveAward(); return(InputComplete()); }
private bool UserRemoving() { consoleSegment = ConsoleSegment.User; Console.Clear(); Console.WriteLine("Choose user by number:"); Console.WriteLine("----------------------"); new OutputPl()?.RemoveUser(); return(InputComplete()); }
private bool AwardsPrint() { consoleSegment = ConsoleSegment.Award; Console.Clear(); var awards = DependencyResolver.AwardLogic?.GetAll(); new OutputPl()?.PrintAwards(awards); Console.WriteLine(); return(InputComplete()); }
private bool UsersAwardsPrint() { consoleSegment = ConsoleSegment.User; Console.Clear(); var users = DependencyResolver.UserLogic?.GetAll(); new OutputPl()?.PrintUserAwards(users); Console.WriteLine(); return(InputComplete()); }
private bool AwardCreation() { consoleSegment = ConsoleSegment.User; Console.Clear(); var outputPl = new OutputPl(); var award = outputPl?.CreateAward(); if (outputPl.AwardAdded(award)) { Console.WriteLine($"---'{award.Title}' added---"); } else { Console.WriteLine($"---'{award.Title}' NOT added---"); } return(InputComplete()); }
private bool UserCreation() { consoleSegment = ConsoleSegment.User; Console.Clear(); var outputPl = new OutputPl(); var user = outputPl?.CreateUser(User.DateFormat); if (outputPl.UserAdded(user)) { Console.WriteLine($"---'{user.Name}' added---"); } else { Console.WriteLine($"---'{user.Name}' NOT added---"); } return(InputComplete()); }
public MovementResult Move(int width, int height, ConsoleApple apple) { ConsoleSegment oldHead = this.body.Last(); ConsoleSegment newHead = new ConsoleSegment( oldHead.X + this.deltas[this.direction].X, oldHead.Y + this.deltas[this.direction].Y, oldHead.Character, oldHead.Color); if (newHead.X >= width || newHead.X < 0 || newHead.Y >= height || newHead.Y < 0) { return MovementResult.Wall; } if (this.IsOn(newHead)) { return MovementResult.SelfBite; } // the following two operations create the effect of motion: // 1. add the new head in front of the old one this.body.Enqueue(newHead); // if the snake is on the apple if (this.IsOn(apple)) { // increase the length by 1, i.e. don't remove the last segment this.removedSegment = null; return MovementResult.OnApple; } else { // 2. remove the last segment this.removedSegment = this.body.Dequeue(); } return MovementResult.OK; }
public MovementResult Move(int width, int height, ConsoleApple apple) { ConsoleSegment oldHead = this.body.Last(); ConsoleSegment newHead = new ConsoleSegment( oldHead.X + this.deltas[this.direction].X, oldHead.Y + this.deltas[this.direction].Y, oldHead.Character, oldHead.Color); if (newHead.X >= width || newHead.X < 0 || newHead.Y >= height || newHead.Y < 0) { return(MovementResult.Wall); } if (this.IsOn(newHead)) { return(MovementResult.SelfBite); } // the following two operations create the effect of motion: // 1. add the new head in front of the old one this.body.Enqueue(newHead); // if the snake is on the apple if (this.IsOn(apple)) { // increase the length by 1, i.e. don't remove the last segment this.removedSegment = null; return(MovementResult.OnApple); } else { // 2. remove the last segment this.removedSegment = this.body.Dequeue(); } return(MovementResult.OK); }