0% found this document useful (0 votes)
46 views7 pages

Acsse Csc2a 2021 Sao2 Mock

This document outlines the details for a summative assessment for the Computer Science 2A module at the Auckland Park Campus, including instructions for completing the assessment, problem modeling tasks related to EnergyCapacitors, file handling with reports, and JavaFX implementation using the Visitor Design Pattern. It specifies the assessment date, duration, marks allocation, and submission guidelines for each question. Additionally, it includes a marking sheet for each question to guide students on the expected deliverables.

Uploaded by

u25476816
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)
46 views7 pages

Acsse Csc2a 2021 Sao2 Mock

This document outlines the details for a summative assessment for the Computer Science 2A module at the Auckland Park Campus, including instructions for completing the assessment, problem modeling tasks related to EnergyCapacitors, file handling with reports, and JavaFX implementation using the Visitor Design Pattern. It specifies the assessment date, duration, marks allocation, and submission guidelines for each question. Additionally, it includes a marking sheet for each question to guide students on the expected deliverables.

Uploaded by

u25476816
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

FACULTY OF SCIENCE

ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING

MODULE COMPUTER SCIENCE 2A CSC02A2

CAMPUS AUCKLAND PARK CAMPUS (APK)

SUMMATIVE ASSESSMENT OPPORTUNITY II MOCK ♠♠♠ SAO2


DATE: 2021-04-13 SESSION: 14:00 - 17:00

ASSESSOR(S): MR. A. MAGANLAL


MR. S. SITHUNGU

MODERATOR: MR. R. MALULEKA

DURATION: 180 MINUTES MARKS: 120

Please read the following instructions carefully:

1. Complete the Honesty Declaration and upload it as part of your submission.


2. This paper consists of 6 pages excluding the cover page.
3. Answer each question in a separate project.
4. By submitting you are bound by the Honesty Declaration for Online Assessments and Assessment
Guidelines set by the University.
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Question 1: Problem Modeling

Problem statement
The Utopian Energy Services Board (UESB) is designing a system to store and report on informa-
tion about its EnergyCapacitors. The EnergyCapacitor is an abstract class that stores charge
amount (a random float between 0 and 255) and provides a reportCharge operation.
There are two (2) kinds-of EnergyCapacitor:
• FunctionalCapacitor has no additional attributes
• VolatileCapacitor stores volatility index (a random integer between 1 and 5)
Each kind of EnergyCapacitor performs the reportCharge operation differently:
• FunctionalCapacitor prints its charge amount to the standard output stream.
• VolatileCapacitor print its charge amount multiplied by volatility index to the standard
output stream.
A ChargeContainer has-an ArrayList of EnergyCapacitors. ChargeContainer contains
an addCapacitor operation to add instances of EnergyCapacitor to the ArrayList. The
ChargeContainer also has a reportAllCharges operation that will call the reportCharge
of each EnergyCapacitor in the ArrayList.

Instructions
For the problem stated above do the following:
1
• Create a UML class diagram that has all the classes with their attributes and operations.
• Create a Java program that contains all the classes with their attributes and operations.
In the Java program create a Main class that will be the entry point of your program. The Main
class must instantiate a ChargeContainer and fill it with ten (10) random instances of Energy‐
Capacitor.
To determine which instance of EnergyCapacitor to instantiate, create a random integer:
• If the integer is even then create a FunctionalCapacitor.
• If the integer is odd then create a VolatileCapacitor.
After the ChargeContainer is filled, call the reportAllCharges method.

Random numbers
In order to get a random number create an instance of the [Link] class. It has the
following methods (that can be useful to answer the question above):
• nextInt(int bound) - Generate a random integer with an upper limit of bound
• nextFloat - Generate a random float between 0 and 1

1
Constructors, accessors and mutators do not need to be shown in the UML Class Diagram.

Page 1 of 6
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q1

Multiple uploads
If you already have submitted once and want to upload a newer version then submit a newer file
with the same name as the uploaded file in order to overwrite it.

Question 1 Mark Sheet


(a) UML Class Diagram
i. Classes [02]
ii. Attributes [02]
iii. Operations [02]
iv. Has-a relationship [02]
v. Is-a relationship [02]
(b) EnergyCapacitor class
i. Abstract [01]
ii. Attributes [02]
iii. reportCharge [02]
(c) FunctionalCapacitor class
i. Correct inheritance [02]
ii. Overrides reportCharge [03]
(d) VolatileCapacitor class
i. Correct inheritance [02]
ii. Overrides reportCharge [03]
(e) ChargeContainer class
i. ArrayList of EnergyCapacitor [01]
ii. addCapacitor method [02]
iii. reportAllCharges method [02]
(f) Main class
i. Instantiate ChargeContainer class [01]
ii. Fill ChargeContainer with FunctionalCapacitor and VolatileCapacitor [06]
iii. Call ChargeContainer reportAllCharges method [01]
iv. Displays results [02]
Total: 40

Page 2 of 6
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Question 2: File handling and Regular Expressions

The Space Observation Society (SOS) needs a Java Program to automate the processing of Re‐
port information from its Space Telescopes. There are two different types of Report: Com‐
pleteReport and IncompleteReport. The SOS has already implemented the Report class
and its children in the provided jar file, [Link]. Reports are stored in text files with the follow-
ing format:
CompleteReport format
1 //Each element is separated by a TAB character
2 RP_ID RP_TELESCOPE [RP_X‐COORD|RP_Y‐COORD|RP_Z‐COORD] RP_MEASUREMENT

RP_ID - the unique ID of the Report, 6 characters long.


RP_TELESCOPE - the name of the reporting Telescope
RP_X/Y/Z‐COORD - the X, Y, and Z coordinate of the measurement
RPMEASUREMENT - a double measurement from the Telescope

IncompleteReport format
1 //Each element is separated by a TAB character
2 RP_ID RP_TELESCOPE RP_ERRORTYPE

RP_ID - the unique ID of the Report, 6 characters long.


RP_TELESCOPE - the name of the reporting Telescope
RP_ERRORTYPE - a description of the ERROR, a variable length String
Create a ReportFileHandler class with a static readReports method. The readReports
method must accept a File handle as parameter and return an ArrayList of Reports read
from the file. The readReports method must read each line of the file and determine if it is
CompleteReport or IncompleteReport using appropriate regular expressions. Based on the
regular expression instantiate the correct class and add it to the ArrayList of Reports. Note:
• The readReports must make sure that the file is opened and closed correctly.
• The readReports must handle any exceptions.
Create a Main class of the program. The Main class must use the readReports method to read
each text of the provided text files. After reading each file iterate through the ArrayList and
display only the CompleteReport on the standard output stream in any format that you choose.

Page 3 of 6
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q2

Multiple uploads
If you already have submitted once and want to upload a newer version then submit a newer file
with the same name as the uploaded file in order to overwrite it.

Question 2 Mark Sheet


(a) ReportFileHandler - readReports method
i. Regular expression for CompleteReport [05]
ii. Regular expression for IncompleteReport [05]
iii. Open file [02]
iv. Read file [05]
v. Test using regular expressions [06]
vi. Instantiation of correct instance [04]
vii. Close File [02]
viii. Return ArrayList of Report [02]
ix. Exception handling [05]
(b) Main
i. Use readReports method to get ArrayList of Report [02]
ii. Display all CompleteReport to standard output stream. [02]
Total: 40

Page 4 of 6
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Question 3: JavaFX and Visitor Design Pattern

The Utopian Digital Artists Association (UDAA) wants a Java program that can be used to
paint tree for its Environmental Painters. The UDAA have provided you with a [Link] file that
contains a set of all the different Shapes. There are many kinds-of Shape: Rectangles, Circles
and Triangles. Each of these classes are documented in the provided JavaDocs. The UDAA re-
quires a program that is capable of painting a set of Shapes onto an Canvas using low-level
rendering techniques. However, they require a separation of concerns as functionality cannot be
added to the classes in the jar file. You must therefore implement the Visitor Design Pattern to
enable the painting of Shape objects onto the canvas. The UDAA instruct you to make use of
only Rectangles and Triangles to test that the program is able to paint a tree such as the one
depicted below:

You must therefore do the following:


2
• Create an IPaintable interface with an appropriate accept method .
• Create an IPaintVisitor interface with a paint method for Rectangle and Triangle.
• Create a TreePaintVisitor class that implements the IPaintVisitor interface. The
TreePaintVisitor class must be able to accept a GraphicsContext from the Canvas
so that it can paint Shapes onto the PainterCanvas.
• Create a PainterCanvas class that must be able to accept an ArrayList of Shapes and
then have the TreePaintVisitor paint them in the redrawCanvas method.
Create a Main class that is a JavaFX Application. The Main class must be able to launch the
application and display a drawn picture of a tree on the Client.
Note: You must instantiate Shapes as you see fit and add them to an ArrayList to be sent
to the PainterCanvas. The PainterCanvas must have the TreePaintVisitor visit each of
these visitable objects to paint them. Your shapes do not need to look exactly like the provided
example.
Remember to place all Visitor-related classes in the [Link] package and the Painter‐
Canvas in the [Link] package.

2
Check the requirement in the JavaDoc for it to be compatible with the [Link].

Page 5 of 6
Computer Science 2A Summative Assessment Opportunity II MOCK 2021-04-13

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q3

Multiple uploads
If you already have submitted once and want to upload a newer version then submit a newer file
with the same name as the uploaded file in order to overwrite it.

Question 3 Mark Sheet


(a) Visitor
i. Create IPaintable interface [02]
ii. Create IPaintVisitor interface [03]
(b) TreePaintVisitor
i. Method to set GraphicsContext [02]
ii. paint Rectangle [04]
iii. paint Triangle [04]
(c) PainterCanvas
i. Has IPaintVisitor instance [02]
ii. ArrayList of Shape [03]
iii. redrawCanvas method - Assigns GraphicsContext to IPaintVisitor [02]
iv. redrawCanvas method - IPaintVisitor visits each Object [08]
(d) Main
i. Create appropriate instances of Shapes [02]
ii. Send instances to PainterCanvas [03]
iii. Show tree [05]
Total: 40

Page 6 of 6

You might also like