Programming II
Assignment 1
Once you are done with your assignment, upload it to eCentennial under Assessments / Assignment / Assignment 1 by the date indicated in the assignment box
Please refer to General Assignment requirements document for the additional requirements
The Direction Enumeration
You will implement the Direction enumeration in Visual Studio
The Sprite Class
This class consist of 10 members as shown below:
Fields:
Properties:
You must use auto-implemented properties.
Name – this auto-implemented property is a string representing the name of the sprite.
Constructor:
Methods:
private bool isCollision(Sprite encounter) – This is a private method that takes an argument of type Sprite. It checks if two sprites, current object and the encounter object are in collision. This method returns true if the objects are in collision and false if they are not. Two sprites are in collision if the distance between their centers is less then the half of the sum of their diameters.
If we have two sprites with coordinates (x1, y1) and (x2, y2) the distance is calculated as: $D = \sqrt{{(x1 - x2)}^{2} + {(y1 - y2)}^{2}}$
Testing
Object named s1 with coordinates (0, 0) and diameter 1 using 2 arguments in the constructor.
Object named s2 with coordinates (1, 1) and diameter 1 using 4 arguments in the constructor.
Console.WriteLine(s3);
s1.Move(Direction.Right);
s1.Move(Direction.Left);
s1.Move(Direction.Up);
s2.Move(Direction.Left);
s1.Move(Direction.Down);