예제 #1
0
        public void CalculateAngle_true()
        {
            Clock newClock = new Clock();

            newClock.SetHour("8");
            newClock.SetMinute("30");
            string expected = "60";

            Assert.AreEqual(expected, newClock.CalculateAngle());

            newClock.SetHour("12");
            newClock.SetMinute("40");
            expected = "120";
            Assert.AreEqual(expected, newClock.CalculateAngle());
        }
        public void CalculateAngle_UserInputsTime12_CalculateDegrees()
        {
            Clock testClock = new Clock("12", "00");

            testClock.SetClockPositions();
            Assert.AreEqual(0, testClock.CalculateAngle());
        }
        public void CalculateAngle_UserInputsTimeUnder12_CalculateDegrees()
        {
            Clock testClock = new Clock("6", "30");

            testClock.SetClockPositions();
            Assert.AreEqual(15, testClock.CalculateAngle());
        }
예제 #4
0
    static void Main()
    {
        Console.WriteLine("Enter the number of hours:");
        float inputHours = float.Parse(Console.ReadLine());

        Console.WriteLine("Enter the number of minutes:");
        int   inputMinutes = int.Parse(Console.ReadLine());
        Clock newObject    = new Clock(inputHours, inputMinutes);
        float result       = newObject.CalculateAngle();

        Console.WriteLine(result);
    }
예제 #5
0
    public static void Main()
    {
        Console.WriteLine("Please enter an Hour");
        string hour    = Console.ReadLine();
        int    newHour = int.Parse(hour);

        Console.WriteLine("Please enter Mins");
        string mins    = Console.ReadLine();
        int    newMins = int.Parse(mins);

        Clock findTime = new Clock(newHour, newMins);

        findTime.CalculateAngle(newHour, newMins);
    }
예제 #6
0
    public static void Main()
    {
        Console.WriteLine("Enter a time:");
        string input      = Console.ReadLine();
        Clock  inputClock = new Clock(input);

        Console.WriteLine("The distance between the hour and minute hands on an analog clock is " + inputClock.CalculateAngle());
    }