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

Acsse Csc2a 2021 Sao2

The document outlines the details for a summative assessment for the Computer Science 2A module at the Auckland Park Campus, scheduled for April 20, 2021. It includes instructions for completing the assessment, guidelines for submission, and specific questions related to problem modeling, file handling, and JavaFX. Each question has a detailed marking scheme and requirements for the programming tasks to be completed by the students.

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)
19 views7 pages

Acsse Csc2a 2021 Sao2

The document outlines the details for a summative assessment for the Computer Science 2A module at the Auckland Park Campus, scheduled for April 20, 2021. It includes instructions for completing the assessment, guidelines for submission, and specific questions related to problem modeling, file handling, and JavaFX. Each question has a detailed marking scheme and requirements for the programming tasks to be completed by the students.

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
You are on page 1/ 7

FACULTY OF SCIENCE

ACADEMY OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING

MODULE COMPUTER SCIENCE 2A CSC02A2

CAMPUS AUCKLAND PARK CAMPUS (APK)

SUMMATIVE ASSESSMENT OPPORTUNITY II ♡♣♠ SAO2


DATE: 2021-04-20 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. You must complete the assessment by yourself within the prescribed time limits.
2. No communication concerning the assessment is permissible during the assessment session except
with ACSSE staff members.
3. You are bound by all university regulations including, but not limited, to assessment, plagiarism, and
ethical conduct.
4. You may not directly take any code from any source, including your own previous submissions. All
code must be written by yourself during the assessment.
5. Answer each question in a separate project.
6. Complete the Honesty Declaration and upload it as part of your submission. The completed Hon-
esty Declaration is required for a submission to be eligible to be marked.
7. Additional time for submission is allowed for as per the posted deadlines on EVE. This additional time
ONLY for submission.
8. This paper contains 3 question(s).
9. This paper consists of 6 page(s) excluding the cover page.
Computer Science 2A Summative Assessment Opportunity II 2021-04-20

Question 1: Problem Modeling

Problem statement
The Flying Chicken Airways is designing a system to store and report on information about
its AeroPlanes. The AeroPlane is an abstract class that stores a current load (a random float
between 0.0 and 100.0) and provides a reportLoad operation.
There are two (2) kinds-of AeroPlane:
• CargoPlane stores highest load limit (a random decimal between 35.0 and 75.0)
• Airbus stores total traveler count (a random integer between 100 and 500)
Each kind of AeroPlane performs the reportLoad operation differently:
• CargoPlane prints its current load as a fraction of the highest load limit to the standard out-
put stream.
• Airbus prints its current load times total traveler count to the standard output stream.
A Airline has-an ArrayList of AeroPlanes. Airline contains an addPlane operation to
add instances of AeroPlane to the ArrayList. The Airline also has a reportTotalLoad
operation that will call the reportLoad of each AeroPlane 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 project that contains all the classes with their attributes and operations. Place
the classes in the csc2a.aero.model package.
In the Java project create a Main class that will be the entry point of your program. The Main
class must instantiate a Airline and fill it with ten (10) random instances of AeroPlane.
To determine which instance of AeroPlane to instantiate, create a random integer:
• If the integer is even then create a CargoPlane.
• If the integer is odd then create a Airbus.
After the Airline is filled, call the reportTotalLoad method.

Random values
In order to get a random number create an instance of the java.util.Random 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 2021-04-20

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q1
Zip the project and submit the zipfile onto EVE.

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) AeroPlane class
i. Abstract [01]
ii. Attributes [02]
iii. reportLoad [02]
(c) CargoPlane class
i. Correct inheritance [02]
ii. Attributes [02]
iii. Overrides reportLoad [01]
(d) Airbus class
i. Correct inheritance [02]
ii. Attributes [02]
iii. Overrides reportLoad [01]
(e) Airline class
i. ArrayList of AeroPlane [01]
ii. addPlane method [02]
iii. reportTotalLoad method [02]
(f) Main class
i. Instantiate Airline class [01]
ii. Fill Airline with CargoPlane and Airbus [06]
iii. Call Airline reportTotalLoad method [01]
iv. Displays results [02]
Total: 40

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

Question 2: File handling and Regular Expressions

The Blue JellyFish (BJF) needs a Java Program to automate the processing of WaterCraft in-
formation from its Shipyard. There are two different types of WaterCraft: CruiseShip and
CargoShip. The BJF has already implemented the WaterCraft class and its children in the
provided jar file, BJF.jar. WaterCrafts are stored in text files with the following format:

CruiseShip format
1 //Each element is separated by a TAB character
2 SHIP_NAME SHIP_STYLE CRUISE_PATRONS

SHIP_NAME - the unique licence plate of the WaterCraft, 6 characters long


SHIP_STYLE - the style of the WaterCraft, 8 characters long
CRUISE_PATRONS - total number of patrons for the CruiseShip, integer

CargoShip format
1 //Each element is separated by a TAB character
2 SHIP_NAME SHIP_STYLE CARGO_LOAD CARGO_TYPE

SHIP_NAME - the unique licence plate of the WaterCraft, 6 characters long


SHIP_STYLE - the style of the WaterCraft, 8 characters long
CARGO_LOAD - load of the CargoShip, float
CARGO_TYPE - type of the CargoShip, ESHIP_TYPE
Create a CraftFileHandler class with a static readWaterCraft method. The readWater‐
Craft method must accept a File handle as parameter and return an ArrayList of Water‐
Crafts read from the file. The readWaterCraft method must read each line of the file and de-
termine if it is CruiseShip or CargoShip using appropriate regular expressions. Based on the
regular expression instantiate the correct class and add it to the ArrayList of WaterCrafts.
Note:
• The CraftFileHandler must be placed in the csc2a.ship.file package.
• The readWaterCraft must make sure that the file is opened and closed correctly.
• The readWaterCraft must handle any exceptions.
Create a Main class of the program. The Main class must use the readWaterCraft method to
read each text of the provided text files. After reading each file iterate through the ArrayList
and display only the following:
• Instances of CruiseShip on the standard output stream in any format that you choose.
• Instances of CargoShip on the standard error stream in any format that you choose.

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

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q2
Zip the project and submit the zipfile onto EVE.

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) CraftFileHandler - readWaterCraft method
i. Regular expression for CruiseShip [05]
ii. Regular expression for CargoShip [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 WaterCraft [02]
ix. Exception handling [05]
(b) Main
i. Use readWaterCraft method to get ArrayList of WaterCraft [02]
ii. Display all instances to correct stream. [02]
Total: 40

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

Question 3: JavaFX and Visitor Design Pattern

The BMH Motors (BMH) wants a Java program that can be used to scan parking for its Park‐
ingLots. The BMH have provided you with a BMH.jar file that contains a set of all the different
AutoMobiles. There are two kinds-of AutoMobile: Cars, Trucks. Each of these classes are doc-
umented in the provided JavaDocs. The BMH requires a program that is capable of scaning a set
of AutoMobiles 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 scaning of AutoMobile objects
onto the canvas. The BMH instruct you to test that the program is able to scan parking such as
the one depicted below:

You must therefore do the following:


2
• Create an IScannable interface with an appropriate accept method .
• Create an IScanVisitor interface with a scan method for Car and Truck.
• Create a ScanGraphicsVisitor class that implements the IScanVisitor interface. The
ScanGraphicsVisitor class must be able to accept a GraphicsContext from the Can‐
vas so that it can scan AutoMobiles onto the ScanCanvas.
• Create a ScanCanvas class that must be able to accept an ArrayList of AutoMobiles and
then have the ScanGraphicsVisitor scan 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 parking on the Client.
Note: use the provided MobileFileHandler to read a file in the data directory to get an Ar‐
rayList to be sent to the ScanCanvas. The ScanCanvas must have the ScanGraphicsVis‐
itor visit each of these visitable objects to scan them.
Remember to place all Visitor-related classes in the csc2a.auto.model package and the Scan‐
Canvas in the csc2a.auto.ui package.

2
Check the requirement in the JavaDoc for it to be compatible with the BMH.jar.

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

Submission Guidelines
Your submission for this question must follow the naming convention below:
SURNAME_INITIALS_STUDENTNUMBER_ CSC02A2_2021_Q3
Zip the project and submit the zipfile onto EVE.

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 IScannable interface [02]
ii. Create IScanVisitor interface [03]
(b) ScanGraphicsVisitor
i. Method to set GraphicsContext [02]
ii. scan Car [04]
iii. scan Truck [04]
(c) ScanCanvas
i. Has IScanVisitor instance [02]
ii. ArrayList of AutoMobile [03]
iii. redrawCanvas method - Assigns GraphicsContext to IScanVisitor [02]
iv. redrawCanvas method - IScanVisitor visits each Object [08]
(d) Main
i. Create appropriate instances of AutoMobiles [02]
ii. Send instances to ScanCanvas [03]
iii. Show parking [05]
Total: 40

Page 6 of 6

You might also like