Reference no: EM132409030
Topic: Classes and Objects
Exercise:
The following activities are similar to the Item Class discussed in class and in the “Item Class – Part 1” hand-out.
The activities are centred around modules that students study on a course of study.
Each module has the following properties:
code (a string)
title (a string)
level (an integer)
cwWeight (coursework weighting, an integer percentage)
exWeight (exam weighting, an integer percentage)
1. Design and implement a class Module that has the above properties.
Your class should define a default constructor that initialises the properties as follows:
code ??????
title No Title
level 0
cwWeight 50
exWeight 50
Your class should define a method that prints each property preceded by appropriate annotation. Each property will be displayed on a single line. Write a short application to test your class.
2. Add a parameterised constructor to your Module class. Write a short application to test your parameterised constructor.
3. Add methods to your Module class to:
set the code
set the title
set the level
set the weights.
This method will accept two parameters in order to set both cwWeight and exWeight
Write a short application to test these methods.
4. Add access methods to get each of the data members of your Module class. Write a short application to test these access methods.
5. Add a method named ask() to your Module class. The ask method should prompt the user for a value of each of the Module data variables. Write a short application to test your ask method.