You are on page 1of 11

Department of Computing

CS 212: Object Oriented Programming


Class: BSCS-13
Lab 10: Open Ended Lab
Date: 29-04-2024
Time: 9:00pm- 12:00 pm
Instructor: Dr. Rehan Ahmad
Lab Engineer: Engr. Masabah Bint E Islam

CS 212: Object Oriented Programming Page 1


Lab 10: Open Ended Lab

Aim:

Objective: Using the knowledge you have acquired so far, please solve the following problem.

Tools/ Software: VS Code, NetBeans, Eclipse etc.

Deliverables: Submit a single file on LMS before the due date as communicated by Lab
Engineer. Please attempt the lab quiz at the defined time.

Note: Write your registration number and name at the top of each code. You will submit your
working codes and outputs (Just Screenshots) in the Lab Report.

Task:

Your task is to design an ecosystem for a university. Define multiple classes for different type of
students (BS, MS), Academic Events (Convocation, Conference) and Departments (Library,
Finance, Exam). The students should receive an invite for convocation or conference only if they
are done with clearance from finance and library and have successfully completed their 4 years
with cgpa of 2.8 or above (for bachelor’s students). The students should receive an invite for
conference if they have completed their degree with cgpa of 3.0 or above and have published a
research paper (for graduating students). Identify Attributes of each class/interface and write
appropriate drive class to test the functionality.

To achieve this task:

1. Design the required UML diagrams and mark the necessary relationships in between.
2. Implement the system using Java programming language

// Muhammad Hassaan Noor


// 470174

public class UniversityTest {

CS 212: Object Oriented Programming Page 2


public static void main(String[] args) {
BS zara = new BS("Zara", 12, true, 2.7);
MS ali = new MS("Ali", 13, true, 3.0, true);
ExamsDepartment exams = new ExamsDepartment();
Library library = new Library();
Finance finance = new Finance();
Conference conference = new Conference("Industrial Scale Organic Content
Marketing");
Convocation convocation = new Convocation("Convocation 2024");

{
/*
* Check BS Student
*/
// send invite for conference only if
// 1. completed their degree
Boolean isDegreeCompleted = zara.isDegreeComplete();
// 2. cgpa >= 2.8
Boolean cgpaAbove28 = zara.getGPA() >= 2.8;
// 3. cleared from library
Boolean clearedFromLibrary = library.isStudentCleared(zara);
// 4. cleared from finance
Boolean clearedFromFinance = finance.isStudentCleared(zara);

if (isDegreeCompleted && cgpaAbove28 && clearedFromLibrary &&


clearedFromFinance) {
conference.sendInvite(zara);
convocation.sendInvite(zara);
}
}

{
/*
* Check MS Student
*/
// send invite for conference only if
// 1. completed their degree
Boolean isDegreeCompleted = ali.isDegreeComplete();
// 2. cgpa >= 3.0
Boolean cgpaAbove3 = ali.getGPA() >= 3.0;
// 3. published research paper

CS 212: Object Oriented Programming Page 3


Boolean hasPublishedPapers = ali.hasPublishedPapers();

if (isDegreeCompleted && cgpaAbove3 && hasPublishedPapers) {


conference.sendInvite(ali);
convocation.sendInvite(ali);
}
}
}
}

public class University


{
public University()
{

}
}

class Student
{
String name;
int id;
Boolean isDegreeComplete;

public Student(String name, int id, Boolean isDegreeComplete)


{
this.name=name;
this.id=id;
this.isDegreeComplete = isDegreeComplete;
}

public String getName()


{
return name;
}

public int getId()


{
return id;
}
public Boolean isDegreeComplete() {

CS 212: Object Oriented Programming Page 4


return this.isDegreeComplete;
}
}

class BS extends Student


{
double gpa;

public BS(String name, int id, Boolean isDegreeComplete, double gpa)


{
super(name, id, isDegreeComplete);
this.gpa=gpa;
}

public double getGPA()


{
return gpa;
}
}

class MS extends Student


{
double gpa;
Boolean hasPublishedPapers;

public MS(String name, int id, Boolean isDegreeComplete, double gpa, Boolean
hasPublishedPapers)
{

super(name, id, isDegreeComplete);


this.gpa=gpa;
this.hasPublishedPapers = hasPublishedPapers;
}

public double getGPA()


{
return gpa;
}
public Boolean hasPublishedPapers() {
return this.hasPublishedPapers;
}
}

CS 212: Object Oriented Programming Page 5


class AcademicEvent extends University
{
String eventName;

public AcademicEvent(String eventName)


{
this.eventName = eventName;
}

public String geteventName()


{
return eventName;
}
}

class Convocation extends AcademicEvent


{
public Convocation(String eventName)
{
super(eventName);
this.eventName = eventName;
}
public void sendInvite(Student student) {
System.out.println("Sending Convocation Invite To: " +
student.getName());
}
}

class Conference extends AcademicEvent


{
public Conference(String eventName)
{
super(eventName);
this.eventName = eventName;
}
public void sendInvite(Student student) {
System.out.println("Sending Conference Invite To: " +
student.getName());
}
}

CS 212: Object Oriented Programming Page 6


class Department extends University
{

public Department()
{
}
}

class Library extends Department


{
public Library()
{
}
public Boolean isStudentCleared(Student student) {
// TODO: implement checking in database
return true;
}
}

class ExamsDepartment extends Department


{
public ExamsDepartment()
{
}
}

class Finance extends Department


{
public Finance()
{
}
public Boolean isStudentCleared(Student student) {
// TODO: implement checking in database
return true;
}
}

CS 212: Object Oriented Programming Page 7


CS 212: Object Oriented Programming Page 8
CS 212: Object Oriented Programming Page 9
CS 212: Object Oriented Programming Page 10
CS 212: Object Oriented Programming Page 11

You might also like