0% found this document useful (0 votes)
11 views5 pages

Practical 4 - 2023

Uploaded by

Desmond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views5 pages

Practical 4 - 2023

Uploaded by

Desmond
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

DEPARTMENT OF COMPUTER SCIENCE AND INFORMATICS

CSIS 1644 – Practical 4

DATE: 14 August 2023


DUE DATE: End of practical sessions

1. All files must include your name and student number at the very top of every file
(The ve concept). Marks are subtracted for every missing occurrence.
2. Your program must run. Marks are subtracted if your program is not executable.
3. Code that is commented out will not be marked.
4. You must use comments to separate your program login. In other words, use
comments to mark the different sections of your code. Comments should be
meaningful.

5. You must use Console (.NET Framework). Marks may be deducted for doing
otherwise.

1. Preparation
• Download the zipped folder named Surname (StudentNumber).zip from Blackboard
under Practical 4.
• Save the zipped folder to the Thawspace (T Drive).
• Right-click on the zipped folder and select Extract All…
• In the window that pops up, make sure the file path indicates that your folder will be
extracted to the Thawspace (T Drive). Click Extract.
• Rename the unzipped folder marked Surname (StudentNumber) to your surname
and student number. Be careful not to rename the folder marked Timetable.

2. Developing your program


Develop a menu-driven console application to display your timetable as in Figure 1. To do so,
add onto the provided code according the question numbers below:
2.1. Open the solution file (.sln file) and view the code that has been provided (Note:
there will be errors until you finished implementing the practical code). You may
not change any of the code unless otherwise stated in the practical
instructions. The following code has been provided:
• Main() method
• Menu() method – used to generate the user menu.
• Partial DisplayTimetable()method – the method is used to generate
the various lines in the rows and columns to depict a timetable.
Do not change any of these methods unless otherwise stated in the practical
instructions.

1
2.2. In the Main() method, declare and instantiate a jagged array named timetable
to store module codes. The array should have 5 rows which will represent the days
of the week. Ensure that you use an appropriate data type.
2.3. Develop a void method named InitializeTable(). This method should
accept the timetable as a parameter and assign a one-dimensional array that can
store 15 elements to each row of the array. Use a for-loop to do this.
• Note: Each element signifies a timetable period (e.g., Period 2).
Therefore, your jagged array should comprise of 5 days where each day
has 15 periods.
2.4. Complete the implementation of the GetEntry() method. This method should
return the module code entry for a specific day and period. The day and period
should be brought in as additional parameters and should be represented as whole
numbers. If the entry is empty, i.e., null, return an empty string. Remember that,
although the user will enter the days and periods starting from1, arrays use zero-
based indexes.
2.5. Complete the DisplayTimetable()method by calling the
GetEntry()method. Remove the comment /*2.5.*/ and replace it with the
GetEntry()method call.
2.6. Complete the SetEntry()method. This method should be used to enter a
module code for a specific day and period (See Figure 2 and Figure 4).
• Read the user’s input for “Day” and for “Period” and perform error
handling. Using only two nested if statements and appropriate
conditions, ensure that the user has entered valid numbers. The number
signifying the day should not be less than 1 or greater than 5. The number
signifying the period should not be less than 1 or greater than 15.
• If the user’s entry is valid, assign the entry to the specified day and period
in the timetable array. Remember that arrays use zero-based indexes and
you will need to make provision for that to prevent an out of bounds error.
2.7. Complete the ClearEntry()method. This method will allow the user to clear a
specific entry for a specific day and period as specified by the user (See Figure 3
and Figure 5).
• Read the user’s input for “Day” and “Period” and perform error handling
as instructed for SetEntry().
• If the user’s entry is valid, set the position in the array to null.
2.8. Complete the the ClearAll()method. This method should clear all of the entries
in the timetable (See Figure 7). Call an existing custom method to reset the array
and clear the timetable.
2.9. In the Save()method, use XML serialization to save the timetable to a file in the
bin\Debug folder named Timetable.xml. You must make sure of a using
2
statement to create a stream to access the file. Display a message to the user
indicated that the file has been saved (See Figure 6).

2.10. Consider the provided Read()method. Adapt the parameter to ensure that the
array in the Main() method and the array in the Read() method refer to the
same memory cell. Make this change to the actual parameter in the Read()
method call as well. If the timetable file exists, deserialize the contents of
Timetable.xml. You must make sure of a using statement to create a stream to
access the file. Call the ClearAll() method if the file does not exist.

Figure 1: Initial Screen

Figure 2: User selects ‘S’ for set entry and


is prompted for day, period, and entry to
make to the timetable.

Figure 3: User selects ‘B’ for clear entry


specifies which timetable entry to clear
based on day and period.

3
Figure 4: Entry made by Figure 5: Entry cleared
user in Figure 2 is by user in Figure 3 is
displayed in timetable. removed in timetable.

Figure 6: The timetable has been successfully saved to the file.

4
Figure 7: User selects ‘C’ for clear all and a
new timetable is generated.
Submission checklist
✓ I have added a comment block with my information before the using directives.
✓ I have zipped my entire solution folder and named it correctly: Surname (Student
number) where Surname and Student number is replaced with my own surname and
student number.
✓ I have downloaded my zipped folder to check that I have submitted the correct project
folder (You must submit the entire project folder, not just the .sln file).

You might also like