Not a member?     Existing members login below:
263 Bestsellers Instantly Yours When You Name Your Price Here

Fundamentals of Computer Programming with C#

Chapter 14. Defining Classes 617
properties and constructors of the class. Also write property of type
Decimal to return the decimal value of the fraction (e.g. 0.25).
26. Write a class FractionTest, which tests the functionality of the class
Fraction from previous task. Pay close attention on testing the function
Parse with different input data.
27. Write a function to cancel a fraction (e.g. if numerator and denominator
are respectively 10 and 15, fraction to be cancelled to 2/3).
Solutions and Guidelines
1. Use enum for subjects and universities.
2. To avoid repetition of source code call constructors from each other
with keyword this(<parameters>).
3. Use the constructor of the class as a place where the number of objects
of class Student is increasing.
4. Display on the console in all fields of the class Student, followed by a
blank line.
5. Define as private all members of the class Student and then using
Visual Studio (Refactor -> Encapsulate Field) define automatically the
public get / set methods to access these fields.
6. Create a few students and display the whole information for each one
of them.
7. You can use the static constructor to create instances in the first access
to the class.
8. Declare three separate classes: GSM, Battery and Display.
9. Define the described constructors and create a test program to check if
classes are working properly.
10. Define a private field and initialize it at the time of its declaration.
11. Use enum for the type of battery. Search in Internet for other types of
batteries for phones, except these in the requirements and add them as
value of the enumeration.
12. Override the method ToString().
13. In classes GSM, Battery and Display define suitable private fields and
generate get / set. You can use automatic generation in Visual Studio.
14. Add a method PrintInfo() in class GSM.
15. Read about the class List<T> in Internet. The class GSM has to store its
conversations in a list of type List<Call>.
16. Return as a result the list of conversations.