St Pauls University Instances Destination Bootstrap Paper

CS 320 Programming Languages (Shen) – Summer 2023Programming Assignment 3 (100 points)
Due Date – Beginning of the class, 12:00PM, 06/27/2023
NO LATE submission will be accepted.
You must do this assignment on your own.
Functional programming is perfect for map, filter, reduce operations for transforming and / or processing
data in a declarative way. Scala has built-in support for performing map, filter, reduce operations for
virtually all collection types. It takes the input collection to create a data stream, then process the data stream
through a series of computation (stream pipeline) on the data elements. The stream pipeline can involve zero
or multiple intermediate operations and one terminal operation. The intermediate operations may transform
each data element through a function of the element (using lambdas) or filter out elements that do not satisfy
some conditions (using lambdas for specifying filtering predicate). The eventual output may be a collection
with transformed and / or filtered data, or an aggregate from performing a computation in the last step such
as sum or average or max of the elements.
In this assignment, you will use Scala to write functional programming style code for exercising data map,
filter, reduce operations.
Task:

Locate the TODOs in Registrar.scala and RegistrarTest.scala and write the implementation for
several functions for transforming data. Refer to the detailed comments there.
Code to start with:


You are given several scala source code files.
You must implement the TODO functions in Registrar.scala and RegistrarTest.scala according to
the specifications in the comment section above each function signature. You may change
Main.scala or RegistrarTest.scala for your testing, do NOT change other files and make your
Registrar.scala dependent on those changes.
Grading:



Autograding accounts for 80 points.
You must use functional programming style to write the TODO code in the Registrar.scala, you
would lose 10 points in grading if you choose to implement any one of them in pure imperative
style.
Your testing code in RegistrarTest.scala is worth 10 points, make sure you complete them as
instructed in the TODOs there.
IntelliJ IDE project for developing, building and testing the code:



Follow the Scala development setup guide on Canvas to set up the dev environment.
Download the scala source code files from canvas.
Create a new Scala project using IDEA or sbt template.
o Use JDK 1.8 or 1.14, use Scala SDK 2.13.8
o Example: Use IDEA project
o
o
o

Example: Use sbt project
In Location: specify the project folder
Very IMPORTANT related to source code compile / build:
▪ For IDEA project:
• All source code files need to be put into the src folder under the project
folder, those files will then be included in the build.
▪ For sbt project:
• All source code files need to be put into the src/main/scala folder under the
project folder, those files will then be included in the build.
Use IntelliJ IDE to build (compile), run or debug your code for testing.
o Go to build menu to build project.
o You can run or debug your code from an entry point in the Main.scala, Scala allows
multiple application entry points.
o In Main.scala
▪ Both Main_demoStreams and Main_registrarTest are called singleton objects that
provide application entry points.
• Main_demoStreams is for demonstrating basic functional programming for
map, filter, reduce using StreamOperation.scala
• Main_registrarTest is where you start the run or debugging of your code
o Refer to comments there for testing

o
To debug or run Main_registrarTest, place the cursor to the beginning of the
Main_registrarTest code, right click to run or debug (set break points) from there.
Test data
▪ The init() in RegistrarTest.scala creates some data for testing. At the end of the init()
function, it does a verbose print using println(registrar) to print all test data (students
and course enrollment data created for testing). You may want to run the test once,
copy the print of the test data for your debugging, then comment out the
println(registrar) there to avoid the verbose print every time you run the test.
Programming references:




Refer to Scala development environment setup guide (posted on Canvas).
Programming in Scala TEXT book.
https://docs.scala-lang.org/scala3/book/introduction.html#
Lecture recording (posted on Canvas)
Turning In
You need to submit the following program artifacts on Gradescope. Make sure that all submitted files
contain your name and Red ID.



You should ONLY submit Registrar.scala and RegistrarTest.scala source files.
Make sure you type the Single Programmer Affidavit (refer to the template on Canvas) as part of
the comments at the beginning of your Registrar.scala file.
Important:
o Upload your files directly to Gradescope.
o Do NOT compress / zip files into a ZIP file and submit, submit all files as they are.
Academic honesty
Posting this assignment to any online learning platform and asking for help is considered academic
dishonesty and will be reported.
An automated program structure comparison algorithm will be used to detect code plagiarism.
• The plagiarism detection generates similarity reports of your code with your peers as well as from
online sources. We will also include solutions from the popular learning platforms (such as Chegg,
etc.) as part of the online sources used for the plagiarism similarity detection. Note not only the
plagiarism detection checks for matching content, but also it checks the structure of your code.
• Refer to Syllabus for penalties on plagiarisms.
• Note the provided source code in the code skeleton would be excluded in the plagiarism check.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper
Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER