Professional Documents
Culture Documents
Oop216d - Oor216d CT5 2024S1
Oop216d - Oor216d CT5 2024S1
Oop216d - Oor216d CT5 2024S1
• Submission of answers:
• Log into EC
• Select [Student], then select [Tests], then select [Web Test 4]
• Select the subject code OOP216D or OOR216D
• Select the intake 20241
• Select the test number M
• Each question will have a separate section on EC where you
CLASS TEST 5 1st Examiner
should paste your answers. Answer each question in its
Duration: 50 min M LIEBENBERG
correct section.
Date: 23 May 2024
• Copy your answers from your source files and paste it in the
Total: 36 Moderator
provided spaces and click “GO” every time you are done. By
Pages: 3
clicking on “GO” you are actually saving your answer for that
question. DO NOT forget to click “GO”.
• Save your work frequently.
• This is a closed book test. NO additional resources, like the
“Debugging is twice as hard as writing the code in the first place. Internet or EC may be used for help.
Therefore, if you write the code as cleverly as possible, you are, by • You may NOT use any flash sticks during the test.
definition, not smart enough to debug it.” • Add your name as a comment on the first line in each file.
Brian W. Kernighan
1
Question 1 (File Manipulation): //20//
For this question, you are provided with an incomplete solution to a concrete class used to read and write records to a sequential text file.
The class consist of a file instance data member that represents the file to be manipulated. The constructor will initialize the file instance data member.
The saveToFile() method will receive the record as a parameter and write it to a new line in the text file.
The readFromFile() method will read all the records from the text file and return them as a list of String values.
Follow the provided code with its comments and fill in the missing code pieces under Section 1 on EC.
2
Question 2 GUI): //16//
Preparation:
1. Create a new NetBeans project called Question2 without a main method.
2. Add a new Java frame class called TriangleGUI to the Question2 project and create the GUI as described below.
Question:
For this question, you will create a basic, but functioning GUI as shown in Figure 1 to calculate the area of a triangle.
Figure 1