OOP - C# Exercises: Excercise 1: Write A Program To Calculate The Area, The Perimeter of The Rectangle
OOP - C# Exercises: Excercise 1: Write A Program To Calculate The Area, The Perimeter of The Rectangle
Excercise 1: Write a program to calculate the area, the perimeter of the rectangle.
- Write class HinhChuNhat includes:
-Attributes: Length, width
-Method:
+ Method setting (set), and getting (get) information for length and width.
+ Method of calculating area, perimeter.
+ The show() method consists of length, width, area, perimeter
information.
- Building the class contains the main function for the test section. Length,
width can enter from the keyboard.
Specifically:
1. Build the class Teacher: abstract class
- Property: code, name.
- Method:
+ Constructor: 2 types (no parameter and full parameters)
+ Get/set methods for all properties.
+ show() method.
+ Get salary – abstract method (only declare without body)
2. Build the class FulltimeTeacher: inherite from class Teacher
- Property: salary coefficient
- Method:
+ Constructor: 2 types (no parameter and full parameters)
+ Get/set methods for all properties.
+ Get salary = salary coefficient * 2000000
3. Build the class ParttimeTeacher: inherite from class Teacher
- Property: slot
- Method:
+ Constructor: 2 types (no parameter and full parameters)
+ Get/set methods for all properties.
+ Get salary = slot * 50000
4. Build an interface, named IManager, design the functions:
- Import and display a list of Teachers (including Fulltime teacher and PartTime
teacher).
- Show list of teachers with the highest salary.
- How many parttime teachers have the slot > 10.
- Calculate the total number of parttime teacher's slots.
- Sort the list of teachers increased by salary.
- Is there a teacher whose name starts with ‘T’? If so, show that person's name
and salary.
- Displays a list of fulltime teachers with the salary coefficient < 3, in which the
full name will separate First and Last Names into 2 columns.
Build the class Manager implement the above interface.
5. Build the main class to excute the above functions. (Show menu and check input).