5062CEM

Programming and Algorithms 2

Recapping Python

Recapping Python

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

classDiagram
    class Student
    Student : + Integer id
    Student : + String name
    Student : + Integer dateOfBirth
    Student : + Integer stage
    Student : + Module[] modules
    Student : - Boolean status
    Student : + __init__(self, name, dateOfBirth, stage)
    Student : + calculate_age(self)

    class Module
    Module : + String id
    Module : + String title
    Module : + Student[] students
    Module : + Assignment[] assignments
    Module : + Integer stage
    Module : - Boolean status
    Module : + __init__(self, id, title, stage)
    Module : + add_student(self, student)
    Module : + add_students(self, students)

    class Assignment
    Assignment : + Integer id
    Assignment : + String title
    Assignment : + Dictionary[] tasks
    Assignment : + Integer totalMarks
    Assignment : + Module module
    Assignment : + __init__(self, _module, _title))
    Assignment : + add_task(id, content, weight)

    Module "1..*" <-- "1..2" Assignment
    Module "1..*" <-- "1" Student 

For this lab activity, you will need to implement the classes that meet the outlines as displayed in the UML diagram.

Note:

  • the methods in each of the classes should return NotImplemented
  • the variable status should be set to True as default
  • the id for Student and Assignment is unique and increments sequentially
  • the + or - denotes whether the attribute is public or private, respectively
  • the totalMarks for the Assignment class is set to 100 as default

For this task, you will need to create several objects of the class Student. You will need to ensure that the id number is incremented automatically for each new object that is created.

Hint: You may want to use the itertools module to assist you in this task.

For this task, you will want to implement the method for the Student class to calculate the age of the student. The variable dateOfBirth should be in the format of 10/03/1954. The method should return the age as an int.

For example, if dateOfBirth is 10/01/1954 then the age 69 should be returned.

Hint: You will want to use the datetime module for this task.

For this task, you will be expected to create a collection of modules for your fictional university. These modules can be for any particular course you wish to implement. It could be based on Ethical Hacking and Cyber Security, or it could be something entirely different - use your imagination.

For this task, you will want to implement a method in the Module class whereby you can assign a single student, and multiple students to the module. There should be a separate method for each functionality.

For this task, you will want to implement a method in the Module class that will return the list of students that are associated with that module. In this instance, we are concerned with a class list, as such just their names should be returned.

For this task, you will need to implement a method in the Assignment class, which will enable you to add tasks for a given assignment. The task should be a dictionary item that consists of an id and the content for that task. An example may be something like:

aTask = {"id": 1,
         "content": "For this task...",
         "weight": 20}

These tasks should then be populated to the tasks list inside that Assignment class.

For this task, you will need to create a method that will add an assignment to a module. However, before the assignment is added to the module, you need to check to ensure that the total number of marks for each task add up to the total number of marks for the assignment.

There will also need to be a cross-check to ensure the assignment is being added to the correct 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.