OOP in C# Tasks
OOP in C# Tasks
OOP in C# Tasks
Lab Manual 05
Introduction
After a week of rigorous coding, Welcome back!
You have learned all about the Classes, Constructors, and member
functions in the previous lab manuals. Let's move on to the next,
new, and interesting concepts.
5. Write the Driver Code (main function) for implementing the menu driven
program.
You have made it through all that. Excellent work students !!!
You guys are successfully en route to be Kamyab Programmers.
There are a few challenges given ahead. Have a try at those. Good Luck :)
Challenge 01:
Miss Client wants to develop a software system for her departmental store. She wants this
system to have the following functionalities.
As an Admin, she can
● Add Products.
● View All Products.
● Find Product with Highest Unit Price.
● View Sales Tax of All Products.
● Products to be Ordered. (less than threshold)
On All Grocery type of products, the sales tax is 10%, on all fruit types the tax is 5% and
if there is any other type the tax is 15%
Make 3 classes
1. Product
2. Customer
3. Admin (MUser) that we have previously developed with file handling
3. Exit
(if the user is valid and admin then show the admin menu)
1. Add Product.
2. View All Products.
3. Find Product with Highest Unit Price.
4. View Sales Tax of All Products.
5. Products to be Ordered. (less than threshold)
6. View Profile (Username, Password)
7. Exit
(if the user is valid and customer then show the customer menu)
1. View all the products
2. Buy the products
3. Generate invoice
4. View Profile (Username, Password, Email, Address and Contact Number)
5. Exit
Implementation Notes:
1. Make BL, DL and UI Class for Admin.
2. Make BL, DL and UI Class for Customer.
3. Make BL, DL and UI Class for Product.
4. If there are some UI functions that do not go into the UI of Admin, Customer or
Product then add a separate UI class with name ConsoleUtility.
Challenge 02:
In this programming exercise, you are tasked with designing a simplified version of
Twitter and Facebook.
Classes:
1. User
Data Members:
● password: A password string.
● messages: A list of stored messages.
● user: A field to store the username.
Member Functions:
● constructor(user, pass): Initializes a User with a username and password,
and messages are initialized as an empty List.
● encryptPassword(str): A method to return the encrypted password using
the following formula.
○ Divide the input str into 3 equal parts, if the str is not equally
divisible by 3 then add # at the end of the str until its size gets
divided by 3.
○ Concatenate the first part at the start of the password, second part at
the middle of the password (round off to integer part incase of odd
size password) and third part at the end of the password.
○ For Example, if the password is “123” and the str is “HELLO”, then
add 1 # at the end. Final str becomes “HELLO#”. Now, the final
encrypted password becomes “HE1LL23O#”
● checkPassword(candidate): Checks if the provided string matches the
password and returns either true or false.
● getPassword(): A function that returns number of asterisks (****)
according to the size of the original password.
● changePassword(newPassword): A function that updates the password to
a new password.
● AddMessage(message): Adds a message to the list of messages.
● getMessage(index): Returns a message stored at the specific index. Return
invalid in case the index is not correct.
● deleteMessage(index): Deletes the message on a specific index.
● deleteAllMessages(): Deletes all messages.
2. Twitter:
Data Members:
● users: A List to store instances of TwitterUser.
Member Functions:
● constructor(): Initializes an empty list of users.
● addTwitterUser(user): Adds a User to the list of users.
● getTwitterUserByUsername(name): Retrieves a TwitterUser instance
based on the provided username or returns null if the user is not in the list.
● getTweets(user): Retrieves the messages of the user the user is available.
3. Facebook:
Data Members:
● users: A List to store instances of FacebookUser.
Member Functions:
● constructor(): Initializes an empty list of users.
● addFacebookUser(user): Adds a User to the list of users.
● getFacebookUserByUsername(name): Retrieves a FacebookUser
instance based on the provided username or returns null if the user is not in
the list.
● getPosts(user): Retrieves the messages of the user if the user is available.
Menu Options
1. User Operations
2. Twitter Operations
3. Facebook Operations
4. Exit
User Operations:
Valid User
1. View Profile
2. Encrypt Password
3. Check Password
4. Change Password
5. Get Password
6. Log Out
Twitter Operations
1. Add TwitterUser
2. View Tweets for a Specific User
3. Post Tweet for a Specific User
4. Back to main menu
FaceBook Operations
1. Add FacebookUser
2. View Posts for a Specific User
3. Add a Post for a Specific User
4. Back to main menu
Implementation Notes:
1. Make a BL Class for User, DL class for all the available users in the system, and
UI class for all the input and output functions of the user.
2. Make BL and UI classes for Twitter and Facebook. Do not need to make a DL
class for these.
3. Implement the Driver Program (Main Function) for the above menus. Make sure
to make an instance of Twitter and Facebook at the start of your program.