5062CEM

Programming and Algorithms 2

Classes and Objects in C++

Classes and Objects in C++

For this activity, you will need to be using an Integrated Development Environment (IDE). The recommended IDE for this module is JetBrains IntelliJ IDEA for Python and JetBrains CLion for C++. You can follow instructions at the following page to set up your development environment:

Setting up your Development Environment

For this task, you are required to implement a class called Student. The class should consist of the following variables:

Variable Name Value
name Ian1
age 331
startDate 13/09/2022
course Ethical Hacking and Cyber Security
degreeClassification ["B.Sc.", "M.Sci.", "M.ScR.", "PhD"]2

1 This can be any value you wish.

2 Pick one of the items from the list, i.e. B.Sc.

The class will have a constructor method to populate the variables. If the degreeClassification value does not match one of those provided in the table above, then an exception should be raised to the user highlighting their mistake. The wording of the exception to be thrown should be:

degreeClassification is not a valid classification, use either: B.Sc., M.Sci., M.ScR. or PhD

For this task, you need to create a function called greeting within class student that provides a default greeting. The greeting should say the following:

Hello name and welcome to course. You are currently studying for a degreeClassification.

Where the degree specification should be worded in its entirety, with the initialism next to it in brackets. See the table below for more information.

Initialism Definition
B.Sc. Bachelor of Science
M.Sci. Master of Science
M.ScR. Master of Science by Research
PhD Doctor of Philosophy

For this task, you are expected to create a function called export_details which will export the details of a given student to a map data type.

For this task, you are expected to create a function called export_all which will export the details of all students that have been created. The details will be exported to a CSV file which will consist of a header detailing the information that is held. For example:

name,age,start_date,course,degree_classification
Ian,32,13/09/2021,Ethical Hacking,BSc
Terry,UNKNOWN,13/09/2021,Ethical Hacking,MSc
James,35,13/09/2021,Ethical Hacking,PhD
Hint

For this function, it is not expected to be within the class student, and you can use the function created in the previous task (exporting to a map) to aid in this solution.

Secondly, the function will require a list to be passed through that contains all of the student details. This will then be written to a CSV file using the csv module.

If you are struggling with this lab activity, you may want to get some additional support. You can speak to the module leader/team in the room of when the lab week is active, or you can visit the Additional Support page for more information on how you can get extra support.