Esempio n. 1
0
        public void It_responds_correctly_to_U_turns()
        {
            var ferry = new Ferry();

            ferry.Steer("L180");
            Assert.AreEqual(180, ferry.Heading);
            ferry.Steer("L180");
            Assert.AreEqual(0, ferry.Heading);
            ferry.Steer("R180");
            Assert.AreEqual(180, ferry.Heading);
            ferry.Steer("R180");
            Assert.AreEqual(0, ferry.Heading);
        }
Esempio n. 2
0
        public void It_responds_correctly_to_example_instructions()
        {
            var ferry        = new Ferry();
            var instructions = File.ReadLines("test.txt");

            foreach (var instruction in instructions)
            {
                ferry.Steer(instruction);
            }
            Assert.AreEqual(17, ferry.X);
            Assert.AreEqual(-8, ferry.Y);
            Assert.AreEqual(25, ferry.ManhattanDistance());
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            var instructions = File.ReadLines(args[0]);

            var ferry = new Ferry();

            //Console.WriteLine(ferry);
            foreach (var i in instructions)
            {
                ferry.Steer(i);
                //Console.WriteLine($"\t{ferry}");
            }
            Console.WriteLine($"Ferry Manhattan distance: {ferry.ManhattanDistance()}");

            var ship = new Ship();

            //Console.WriteLine(ship);
            foreach (var i in instructions)
            {
                ship.Steer(i);
                //Console.WriteLine($"\t{ship}");
            }
            Console.WriteLine($"Ship Manhattan distance: {ship.ManhattanDistance()}");
        }