You are on page 1of 3

PROGRAMMING IN C# - PRACTICAL

youll have to create a Books Management system. The system allows input, list, search books.
1. Create an interface name IBook contains these properties and methods: (Total : 4

points) a. Properties
i. ID (int) ii. Name (string) iii. PublishDate (DateTime) iv. Author (string) v. Language (string) vi. AveragePrice (float) Read only property

b. Methods i. bool AddNew() ii. void Display()


iii. bool Delete (int id) iv. void Find(int id) 2. Create a class name Book a. Implements the IBook interface b. The method Display will print all Name, PublishDate, Author, Language and

AveragePrice of the book to the console c. Method Delete(int id) will be return true if delete success a book else return false
d. Method Find(int id) will be display all information if find a book and display

message Book Not Found


e. Declare an array name PriceList type int has size of 5 elements (0.5 point)

f. Create an indexer uses the array PriceList g. Create a method named Calculate to set AveragePrice = average of 5 int

elements in PriceList array.


3. Display a tasks menu to choose (Fig.1)

4. If user type 1 from keyboard then:

a. Create a Hastable or dictionary (create only one Hastable or Dictionary) to keep the Book instance in step a with key = ID and value = the Book instance
b. Create a new Book instance and input Name, PublishDate, Author, Language

and then ask user to enter 5 prices and set to the instance indexer - The ID is auto increament ( ID++ ) - Be sure to check format of PublishDat
5. If user type 2 from keyboard then:

Loop from all book instances in the Hastable then executes the Display method from IBook interface.
6. If user type 3 from keyboard then:

Allow user input id of a book and execute Delete method


7. If user type 4 from keyboard then:

Allow user input id of bool and execute Find mehod


8. If user type 5 from keyboard then:

Method AveragePrice Loop from all book instances in the Hastable then executes the Calculate method and then executes the Display method
9. While user not chooses Exit (type 4 from keyboard) then go back to the menu step 3

to ask user chooses an option. 10. handling all exception can occur.

You might also like