Beispiel #1
0
    public override string ToString()
    {
        var result = new StringBuilder();

        result.AppendLine(Name);

        result.AppendLine("Company:");
        if (TheCompany != null)
        {
            result.AppendLine(TheCompany.ToString());
        }

        result.AppendLine("Car:");
        if (TheCar != null)
        {
            result.AppendLine(TheCar.ToString());
        }

        result.AppendLine("Pokemon:");
        Pokemons.ForEach(p => result.AppendLine(p.ToString()));

        result.AppendLine("Parents:");
        Parents.ForEach(p => result.AppendLine(p.ToString()));

        result.AppendLine("Children:");
        Children.ForEach(c => result.AppendLine(c.ToString()));

        return(result.ToString());
    }
Beispiel #2
0
        public void DriveTheCar()
        {
            if (drivingCommands.Count > 0)
            {
                DriveCommands command = drivingCommands.Dequeue();

                if (command == DriveCommands.Move)
                {
                    TheCar.Move(map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.CloseGate)
                {
                    TheCar.CloseGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.OpenGate)
                {
                    TheCar.OpenGate(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.PickupDirt)
                {
                    TheCar.PickUpDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.DropDirt)
                {
                    TheCar.DropDirt(ref map[GetRowInFront(TheCar), GetColumnInFront(TheCar)]);
                }
                else if (command == DriveCommands.RotateLeft)
                {
                    TheCar.RotateLeft();
                }
                else if (command == DriveCommands.RotateRight)
                {
                    TheCar.RotateRight();
                }
            }
        }