ModuleTest1 2016
ModuleTest1 2016
CSIS1624
SECTION A (21)
Answer the following questions on the answer sheet that is provided.
The computer must be switched off while you are completing Section A.
This is not an open-book test.
1
3. Draw a UML Class diagram for the following scenario:
Base class CVehicle, with the following:
o a private string data field for its registration number,
o a public string property for its registration number,
o a public int property for its age,
o a public abstract method named ShowInfo with return type string.
Class CCar that is derived from CVehicle, with the following:
o a public int property for the number of cylinders it has. (13)
2
SECTION B (81)
Remember to add a comment block containing your student number, name and
surname, today's date and the name of the question at the top of every class. Marks
will be deducted for each file where the comment block is missing.
Adhere to all programming and naming conventions as taught and ensure that your
code is aligned properly.
This is not an open-book test.
Question 1 (40)
Create a C# Windows Forms application using Visual Studio and name your project
Question1.
The application should allow the user to input the details of football players and should then
list all players that have been added, as in the screenshot below.
Add a class called CPlayer.cs to your project. This class should contain the following:
Read-only auto-implemented properties for the name of the player, the number of goals
he has scored and the number of assists he contributed.
A private data field for the player’s age, accompanied by a public property. The relevant
accessor of the property should ensure that a player’s age is no less than 15 and no more
than 45. If values outside this range are encountered, they should be replaced by the
closest acceptable value.
3
A constructor that accepts the player’s name, age, goals and assists as parameters and
assigns them to the appropriate properties.
A Description() method that returns a string summarising the player’s information in one
line for the purpose of displaying it in the listbox, as in the screenshot.
Question 2 (41)
Create a C# Windows Forms application using Visual Studio and name your project
Question2.
The application should let the user select a shape and then display relevant details, as in the
screenshots below.
4
Add an abstract class CShape.cs to your project that contains the following:
Three auto-implemented properties for the name, number of sides and area of the
shape.
A virtual method, Summary(), that returns a string which summarises the properties of
the shape as is displayed in the richtextbox in the screenshots.
Add three sub-classes of CShape.cs to your project and name them CCircle.cs, CTriangle.cs
and CSquare.cs. Each of these three classes must contain the following:
Auto-implemented properties for the information used to calculate the area of the
shape. For a circle its radius is required, for a triangle its base and height is required,
and for a square its side length.
A constructer that accepts parameters for the properties mentioned in the previous
bullet and assigns them to the appropriate properties. Any negative values for the
parameters should be changed to 0 and then assigned to the properties. The area of
the shape should be calculated and assigned here (use the formulas at the end of this
document). The remaining properties, of which the values should be self-evident, but
can be read from the screenshot otherwise, must also be assigned values here.
The Summary() method of the base class must be overridden to add the information
that is unique to each shape.
5
Submission Procedure
When you are ready to submit, add both your project folders to a single folder and rename
that folder to your student number. Submit a .zip archive of the folder on Blackboard.