Assignment 02 – Spring 2020 Please note that the marks of this assignment will contribute to your mid term 2 and the assessment will be based on the practical examination/demonstration of the code you submit.
- Modify your console-based Exam Management System from Assignment 01. Note that you can use this assignment to demonstrate your concepts of object-oriented programming including classes, objects, composition, inheritance, polymorphism, abstract classes, interfaces (not GUI). Major Classes are Student, Course, Paper and Faculty. You can add more classes as you deem appropriate. For example, you can add a super class where you think some of the classes have shared details, and subclasses where a type of a class needs to have more specific details, i.e., Undergraduate and Postgraduate students, BSSE, BSCS, MCS students, final exam papers, and mid semester papers etc. Note that a final exam paper need to be invigilated by a faculty member and has a separate time slot and a fixed date and location. Think about what instance variables you should define. Perform exception handling and data validation where necessary. You can consider the following details as hints while writing your code.
- Start by drawing a UML diagram showing the names, instance variables, methods and relationships among the classes. You can use any open source tool to draw the UML diagram.
- Common details of the Student and Faculty can be combined into a super class Person. A person has a name, address, phone number and e-mail address. The name of the person once assigned cannot be changed. Validate the values for these data members using Regular Expressions, such that a name can only contain alphabets from A to Z or a to z and the first letter is always a capital letter. The address should start with a number followed by one or two words (for example 16 Khyber or 16 Khyber Ave). The phone number should have a format like 0-000-0000000 where the first digit is always a 0. The e-mail address should contain exactly one ‘@’ character and at least one ‘.’ character. Note that the system does not store information about individual person, so the Person must be either a student or a teacher.
- The Faculty class stores information about the name and the courses allocated to the faculty. The Course class stores the information about the course code and the course name, and the associated book from the library. Use regular expressions to verify that the first two characters in the course code are CS, followed by a non-zero integer, and the first alphabet in the name of every letter in the course is capital. The faculty class should have the required setter and getter methods along with a toString method that displays the name and course details.
- The system might want to use a method common across all the relevant classes to maintain the finances. You can use an Account interface that includes a method declaration to be implemented by the relevant classes. The finances include expenses in the form of the logistics such as printouts, refreshments and stationary purchases, and earnings in the form of the fine for late submission of a paper. More about interfaces can be found here https://www.studytonight.com/java/java-interface.php
- Implement a Paper class. A paper can either be of Mid Term Exam or Final Term Exam. An object of the class should keep track of the following information: paper’s title, paper’s id number and whether the paper is scheduled or not. All the instance variables should be private. a. Write a constructor for the Paper class that takes the title, number of students and the id number. By default, a newly created paper is not scheduled. b. Write the get methods for all the fields. Write a set method for the instance variable that specifies whether the paper is scheduled. Note that because being scheduled is a Boolean value, by convention, the names you should use should be similar to isScheduled() and setIsScheduled(). c. You can use collections (ArrayLists or maps) to store multiple students for the papers, multiple papers for the course and multiple courses for the teachers. (additional: can you associate the students marks for the paper using these data structures?) d. Write a toString() method.
- Write a Test class with a main method that creates three Paper objects. Then use System.out.println() to print the objects. Along with other details, it should also return the number of students in the paper.
- Implement a Course class. A course object keeps track of the following information: course’s name, course code, program name (BSSE, BSCS, MCS), semester the course is offered in (e.g. Fall 2020) and the semester paper. All the instance variables should be private. What type should you use for the semester paper (a collection of semester papers)? a. Write a constructor for the Course class. The constructor takes as parameter the name and the course code of the course. By default, a newly created course does not have any papers. b. Write a get method for the name and course code field. Write a set method for the course code. The name of the course cannot be changed once it has been created. c. Write an addPaper() method that receives a Paper. And adds it to the collection. d. Write a contains method that takes the name of a paper (i.e. does NOT take a Paper object as its parameter, takes only the name) and determines whether the course has that paper in its collection. e. Fine is imposed at the rate of Rs 100 per day if the mid paper is taken later than the scheduled date. A final paper cannot be rearranged. f. Write a toString() method. How can we make use of the toString() method of Paper when writing the toString() of Course? Modify the main method to create two Course objects. Associate papers with courses. Print courses using System.out.println().
- Use polymorphism to display the details for the students, teachers, courses and papers. How would you increase the fine of a Software Engineering student, that is a subclass of the Student class, by 25%, using enhanced for loop.
- Play with the code. Do various things. Make yourself comfortable about how objects work. E.g. Ask the user to enter a paper title, then display if the paper exists in any of the papers, and if so, which one. The requirements given are minimal and further details can be added where necessary.
- The system should also keep track of the number of students, teachers and books.