Final Exam - PROG1815 Programming Concepts II

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Final Exam – PROG1815 Programming Concepts II

Please read the following instructions carefully before beginning the exam

Submissions will not be accepted after the final exam time, including email.
 Total time to attempt this exam is 3 Hours (total points 82).
 Ensure ALL work intended to be submitted is uploaded when the exam is completed.
 Note: MISSED / FORGOTTEN / unzippable work will not be accepted after the allotted exam time.
 NOTE CAREFULLY:
 You may refer to the textbook, class notes & slides
 All programs are to be written in Widows Forms App (.NET Framework) using the Visual Studio IDE
 You may NOT use the internet or any other person for help
 Attempt this exam on your own; do not share files or communicate with anyone but your teacher during this
exam. The details of this exam may NOT be shared in part or in whole with anyone - Any student linked to or
caught doing this will be subject to an academic offence. In accordance with the school policy of fairness to all
students, any work submitted that is found similar, to any work submitted from the class, across sections, or
work attempted by any other person except you - the registered student, will result in an automatic zero for the
total exam.
Note this can also result in failure of the course. By submitting this exam, you have further indicated to have read
and understood these guidelines.

 Periodically zip (must be WINZIP format) and upload your solution to the relevant assignment folder on the
course site and ensure you upload your final solution by the due time. All uploads are tracked, only the last one
will be marked.
 All submission MUST be submitted to the dropbox. Email attachments will NOT be accepted.
 Read all questions carefully before answering.

All the Best

1. Use Visual Studio to create a windows project called XXFinalExam, where XX are your initials.

Overview
Create software to record personal trainer appointment information for a local gym, which is saved to a text file through
an encapsulated class. The Text file name is defaulted to Trainer.txt, and you MUST use the default location for your
file and add 4 test records to the file.

For your solution do not create a global collection such as an Array, a List, a ListBox or String to store multiple records in
memory or on the GUI. These will not be considered.

Trainer Class
[2 marks] Create a separate class file called Trainer. Methods are instance methods unless stated otherwise.

1. [4 marks] Your class must contain the following public properties:


a. TrainerId – Int32, unique, greater than zero.
b. ClientName – String, required, at least 2 words, each at least 2 letters, could include other characters
c. Contact – String, required, must be either an email (pattern: [email protected]) or a phone
number (pattern 123-123-1234)
d. AppointmentDate – DateTime, displayed 2021-04-29, must be in future for an Add
e. AppointmentTime – DateTime, displayed 08:10 AM, must be between 8:00 AM and 9:00 PM
f. FollowupRequired – Boolean, default true. (If the client needs follow up sessions with trainer)
g. FollowupDate – DateTime, displayed 2021-05-27
h. FollowupTime – DateTime, displayed 08:10 AM
2. Create the following class-level Get methods (In the Trainer class):
a. [3 marks] GetTrainerRecords – This method reads all the records from the text file and returns a list
List<Trainer> of all records.
b. [4 marks ] GetTrainerRecordById - This method accepts a trainer ID and uses logic (including stream
reader) to search the text file and return an object with the matching record properties (as outlined in #1
above)
c. [3 marks] GetUniqueTrainerId - This method must generate a unique number (Trainer ID); It can be
based on the previous ID(i.e. generate a number not used before) – can get this by reading the last ID
number saved in the file.
3. Create an Add method (private) in the Trainer Class and accepts a Trainer object parameter:
a. [3 marks] This method must Add the Trainer object to the file.
b. [2 marks] This method must throw any exception encountered back to the caller, with a description
identifying the action attempted.
4. Create an Update method (private) in the Trainer Class and accepts a Trainer object parameter:
a. [3 marks] The method must replace the record having the same TrainerId with this update object.
b. [3 marks] This method must throw any exception encountered back to the caller, with a description
identifying the action attempted.
5. Create an Validate method in the Trainer Class:
a. [3 marks] This method must verify the criteria mentioned in the properties (question 1 above).
b. [3 marks] All error messages are thrown at once in an exception, one field per message, delineated so as
to display one message per line.
6. Create a Save method in the Trainer Class and accepts a Trainer object parameter :
a. [1 mark] Calls the object’s Validate method created above
b. If FollowupRequired is true (see properties in question 1):
i. [2 marks] Set the FollowupDate to the same day of the week, 4 weeks after the
AppointmentDate.
ii. [2 marks] Sets the FollowupTime to be the same as the AppointmentTime.
c. [2 marks] If TrainerId is not on file, call the object’s Add method.
d. [2 marks] If TrainerId is on file, call the object’s Update method.
7. Create a ToString override method in the Trainer Class (hint: used in the Save method for add or update):
a. [3 marks] This method must return the Trainer object’s properties in a single tab delimited string.
8. Create a method (static) called “CheckFile” in the Trainer Class:
a. [2 marks] This method must confirm or create the output file, if missing (“Trainer.txt” in the current
directory).
TrainerSchedule Form
9. [3 marks] Create the following form with your name in the caption, as shown.
a. The display area at the bottom is a RichTextBox.

10. New Appointment button:


a. [2 marks] This clears the input controls and use the class’ GetUniqueTrainerId to pre-load the TrainerId.
11. Save button
a. [3 marks] Create an object of the Trainer class and populate its properties from the input fields.
b. [2 marks] Call the Save method and pass the object from a. above as a parameter.
c. [3 marks] Catch and display any exceptions in a message label or the display area.
12. Display Future Appointments button:
a. [3 marks] Fetch all Trainer records from file, ordered by ClientName (include the method
GetTrainerRecords).
b. [4 marks] Display each Trainer object (records) in the rich text box, with an Appointment Date or
FollowupDate only if the appointment date is today(current date) or later:
i. [2 marks] Align each field under the appropriate heading in the rich text box
ii. [2 marks] Dates & Times formatted as shown
iii. [3 marks] Only show the FollowupDate & Time if FollowupRequired is true
iv. [2 marks] Only 1 record per line – format as shown in diagram
13. Exit button:
a. [1 mark] Closes the form

You might also like