C# - C Sharp: Practical 5: News Management System
Giải phóng thời gian, khai phóng năng lực
NEWS MANAGEMENT SYSTEM
1. Create an interface name INews contains these properties and methods:
a. Properties
ID (int)
Title(string)
PublishDate (DateTime)
Author (string)
Content (string)
AverageRate(float) – Read only property
b. Methods
void Display()
2. Create a class name News:
a. Implements the INews interface in step 1
b. The method Display will print all Title, PublishDate, Author, Content and AverageRate of the news to the console
c. Declare an array name RateList type int has size of 3 elements
d. Create an indexer uses the array RateList in step 2c.
e. Create a method named Calculate to set AverageRate = average of 3 int elements in RateList array.
3. Display a tasks menu to choose:
1. Insert news
2. View list news
3. Average rate
4. Exit
4. If user type 1 from keyboard then:
a. Create a new News instance and input Title, PublishDate, Author, Content and then ask user to enter 3 rates and set to the instance indexer
- The ID is auto increament ( ID++ )
- Be sure to check format of PublishDate
b. Create a Hastable (create only one Hastable only) to keep the News instance in step a with key = ID and value = the news instance.
5. If user type 2 from keyboard then:
Loop from all news instances in the Hastable then executes the Display method from INew interface.
6. If user type 3 from keyboard then:
Loop from all news instances in the Hastable then executes the Calculate method and then execute the Display method.
7. While user not chooses Exit (type 4 from keyboard) then go back to the menu step 3 to ask user chooses an option.
Giải phóng thời gian, khai phóng năng lực