Created
May 6, 2014 03:12
-
-
Save kuanyingchou/7b7bc58b0ef60bcb9499 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class KZAnalogClock { | |
public int GetHour(); | |
public int GetMinute(); | |
public int GetSecond(); | |
public void SetTime(int h, int m); | |
public void SetTime(int h, int m, int s); | |
public void SetHourAngle(float angle); //hour effects hour only | |
public void SetMinuteAngle(float angle); //minute effects hour | |
public void SetSecondAngle(float angle); //second effects minute & hour | |
public float GetHourAngle(); | |
public float GetMinuteAngle(); | |
public float GetSecondAngle(); | |
} | |
public class Test { | |
[Test] | |
public void TestClock() { | |
KZAnalogClock clock = new KZAnalogClock(); | |
clock.SetTime(0, 0); | |
Assert.That(clock.GetHourAngle(), Is.EqualTo(90)); | |
Assert.That(clock.GetMinuteAngle(), Is.EqualTo(90)); | |
clock.SetTime(3, 0); | |
Assert.That(clock.GetHourAngle(), Is.EqualTo(0)); | |
Assert.That(clock.GetMinuteAngle(), Is.EqualTo(90)); | |
clock.SetTime(6, 0); | |
Assert.That(clock.GetHourAngle(), Is.EqualTo(-45)); | |
Assert.That(clock.GetMinuteAngle(), Is.EqualTo(90)); | |
clock.SetTime(9, 0); | |
Assert.That(clock.GetHourAngle(), Is.EqualTo(180)); | |
Assert.That(clock.GetMinuteAngle(), Is.EqualTo(90)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment