Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CS 5004 Midterm Exam - Summer 2022, Version 3

• This is a computer-based exam. That means that you will use your own computers to individually work on the problems during the designated exam time, and you will submit your solutions by rst trying to push them to your individual repos on our GitHub course organization. If Github isnt available, please zip/tar your src folder, build.gradle le and any UML diagrams you may want to submit, and upload everytning on Canvas.

 The exam will be opened between 12 noon PT until 7pm PT, on Tuesday, June 28th.

• During your chosen exam day, you are welcome to spend up to ve hours working on the exam problems.

• When pushing code to your individual repo, you will want to use our course Gradle project (the same Gradle project, and the corresponding build le that we have been using throughout this course).

• Additionally, we will use submission rules similar to those we followed for the homework assign- ments:

  Repository content: Your repositories should contain only the build .gradle file and src folder with appropriate sub-folders with your code and tests.

  Naming convention: Your solution to each problem should be in its own package. The package names should follow naming convention midtermExam .problemM, where you replace M with the problem number, e.g., all your code for problem 1 for this exam must be in a package named

midtermExam .problem1.

  Gradle built: Your project should successfully build using the course Gradle archetype, and it should generate all the default reports.

Some additional expectations and restrictions:

  Naming convention: Please follow the naming convention for classes, methods, variables, con- stants, interfaces and abstract classes that we have been following throughout this whole course (camel case). Please avoid magic numbers.

  Methods hashCode(),  equals(),  toString(): if required, your classes should provide appropriate implementations for methods:  boolean  equals(Object  o),  int  hashCode(),  String  toString().  Ap- propriate means that it is sufficient to autogenerate these methods, as long as autogenerated methods suffice for your specific implementation. Please don’t forget to autogenerate your meth- ods in an appropriate order - starting from the ancestor classes, towards the concrete classes.

 Testing your code: tests are required only if/where specically asked for in the assignment.

 Javadoc: when asked, please include a short description of your class/method, as well as tags @params  and @returns in your Javadoc documentations (code comments).  Additionally, if your method throws an exception, please also include a tag @throws to indicate that.

 UML diagrams: Please include UML diagrams only when explicitly asked for it.

Problem 1                                                                                                                                                   (50 pts)

(a) You are a part of a company developing automated tools for tracking, prediction and optimization    (10 pts) of employees’ producivity.  Employees’ productivity is a function of many complex parameters,

but at this stage, your company models and estimates productivity as follows.

The productivity tracking system distinguishes between two kinds of employees:

Full-time employees

 Part-time employees

A full-time employee can be:

 Individual contributor

 Manager

A part-time employee can be:

Benets-eligible employee

Hourly employee

For every employee, the productivity tracking system keeps track of:

  Employee ID, a unique employee identier, represented as a String.

•  Contact info, represented as a ContactInfo, a custom class that has already been developed for you. This class keeps track of:

  Name, employee’s rst and last name, represented as a Name, another custom class that has already been developed for you.

 Address, an employees address, represented as a String,

  Phone number, the employees phone number, represented as a String,

  Email address, the employees email address, represented as a String,

  Emergency contact, the employees emergency contact, represented as a Name.

•  Employment date, the date the employee started working at their current company, repre- sented as LocalDate.

•  Employment level, represented as an EmploymentLevel, a custom enum that has already been developed for you, with possible values: Entry level, Intermediate level, Mid-level, Senior level, Executive level.

  Last years earnings, represented as a Double.

Additionally, for every full-time employee, the system keeps track of:

•  Base pay, the employees base pay, as dened by the contract, represented as a Double.

  Bonuses, the employees last year earned bonuses, represented as a Double.

•  Overtime, the employee’s last year’s earnings due to overtime payments, represented as a Double.

  Date of the last promotion, the date of the employees last promotion, represented as a LocalDate.

•  Number of projects, the number of projects an employee is working on, represented as an Integer.

Further, for every part-time employee, the system keeps track of:

• The contractual number of worked hours, denoting the number of hours an employee is contractually expected to work per week, represented as a Double.

The actual number of worked hours, denoting the actual number of hours an employee worked last week, represented as a Double.

•  Bonus and overtime earnings, denoting the combined bonus and overtime earnings, repre- sented as a Double.

Further, for every manager, the system keeps track of the number of employees they manage, represented as an Integer.

Please provide the UML Class diagram for your complete design of the employee productivity estimation system.

(b) The system estimates an employees productivity according to the following rules:                              (15 pts)

•  Base productivity estimate for full-time employees: Base productivity of full-time employees is calculated as a ratio between an employee’s last year’s earnings, and their base pay.

•  Base productivity estimate for part-time employees: Base productivity of part-time employ- ees is calculated as a ratio between an employee’s actual number of worked hours, and their contractual number of worked hours, and the result is multiplied by 5.

•  Number of projects bonus: Every full-time employee involved in more than 3 projects gets a bonus boost where 1.2 is added to their base productivity estimate.

•  Manager bonus: Every manager who manages more than 8 employees gets a bonus boost, where 1.7 is added to their current productivity estimate.

•  Employment level bonus: If an employee is hired into the intermediate level role, they get a bonus boost, where 1.3 is added to their current productivity estimate.

•  Last promotion penalty: For every full-time employee, if more than three years have passed since their last promotion, they get a penalty, where 0.8 is subtracted from their current pro- ductivity estimate.

•  Hourly earnings bonus: If an hourly employee’s hourly rate is less than $15, they get a bonus boost, where 2 is added to their current productivity estimate.

Design and implement method estimateProductivity(), whose return type is Double.  That means that when we call method estimateProductivity() on some Employee, it should return an estimated productivity for that employee as Double.

(c) Please provide test class(es) for the class Full -time  employee, and its subclasses.                                     (15 pts)

(d) The company has decided to add another type of an employee, a Consultant.  Consultants are    (10 pts) unrelated to full-time and part-time employees, and for all consultants, the system keeps track of                the following:

•  Consulting rate, denoting the contractually obligated hourly rate paid to the consultant, and represented as Double.

•  Contractual number of consulting hours, denoting the number of hours the consultant is expected to be available per month, and represented as Integer.

Actual number of consulting hours, denoting the actual number of hours the consultant worked last month, and represented as Integer.

For all consultants, the system estimates their productivity according to the following rules:

• The base productivity of a consultant is equal to the difference between their actual number of consulting hours, and their contractual number of consulting hours, divided by 100.

Please provide implementations for the added Consultant, and their corresponding estimateProductivity() method.

Problem 2                                                                                                                                                   (50 pts)

(a) You are a part of a team developing a new system to keep track of, and manage academic research    (10 pts) papers, referred to as the academic publishing system. This academic publishing system contains                information about individual research papers published in major research conference proceedings,                magazines and journals.

Your team is tasked with specifying an ADT AcademicPublishingSystem, which will be used to store and manage information about research papers.

A class ResearchPapers, which stores information about research papers is provided below for your convenience.

Your ADT AcademicPublishingSystem will need to support the following functionality:

 Check whether or not the AcademicPublishingSystem is empty.

 Count the number of ResearchPapers in the AcademicPublishingSystem.

• Add a ResearchPaper into the AcademicPublishingSystem. Please note that AcademicPublishingSystem does not allow duplicate ResearchPapers.

• Remove a specified ReserchPaper from the AcademicPublishingSystem. If the ReserchPaper does not exist in the AcademicPublishingSystem, the system should throw ResearchPaperNotFoundException, which you will have to implement yourself.

 Check for a specied ResearchPaper in the AcademicPublishingSystem.

• Find and return all ResearchPapers from the AcademicPublishingSystem published in the same pub- lishing venue, provided as input argument, String  publishingVenue.

• Find and return all ResearchPapers from the AcademicPublishingSystem published by the same cor- responding author, provided as input argument, Name  correspondingAuthor.

• Get a Researchpaper  from the AcademicPublishingSystem based upon the ResearchPaper’s unique identifier, paperID. The system throws an InvalidResearchPaperIDException if the given unique ID

doesn’t exist. You are expected to implement InvalidResearchPaperIDException for yourselves.    The AcademicPublishingSystem is envisioned as a linked collection of ResearchPapers, and it can be mutable or immutable.  Please write an interface for the AcademicPublishingSystem  ADT. Please include Javadoc for every method.

(b) The AcademicPublishingSystem is envisioned as a linked collection of ResearchPapers.                                 (25 pts)

Please implement AcademicPublishingSystem ADT using either an array-based, a sequential or a recursive implementation of a linked data collection.  Include a UML class diagram for the complete AcademicPublishingSystem ADT.

(c) Please write unit tests for the following subset of the AcademicPublishingSystem ADT methods:              (15 pts)

 Check whether or not the AcademicPublishingSystem is empty.

 Check for a specied ResearchPaper in the AcademicPublishingSystem.

• Remove a specified ReserchPaper from the AcademicPublishingSystem. If the ReserchPaper does not exist in the AcademicPublishingSystem, the system should throw ResearchPaperNotFoundException, which you will have to implement yourself.

• Find and return all ResearchPapers from the AcademicPublishingSystem published by the same cor- responding author, provided as input argument, Name  correspondingAuthor.

Please note that you do not have to provide tests for any other methods of the AcademicPublishingSystem

ADT.

package  problem2;

import  java .util .Objects;

/*

*  Class  Name  contains  information  about  a  persons  first,  middle  and  last  name .

*/

public  class  Name  {

private  String  firstName;

private  String  middleName;

private  String  lastName;

public  Name(String  firstName,  String  middleName,  String  lastName)  {

this .firstName  =  firstName;

this .middleName  =  middleName;

this .lastName  =  lastName;

}

public  String  getFirstName()  {

return  firstName;

}

public  String  getMiddleName()  {

return  middleName;

}

public  String  getLastName()  {

return  lastName;

}

@Override

public  boolean  equals(Object  o)  {

if  (this  ==  o)  return  true;

if  (!(o  instanceof  Name))  return  false;

Name  name  =  (Name)  o;

return  Objects .equals(getFirstName(),  name .getFirstName())  &&

Objects .equals(getMiddleName(),  name .getMiddleName())  &&

Objects .equals(getLastName(),  name .getLastName());

}

@Override

public  int  hashCode()  {

return  Objects .hash(getFirstName(),  getMiddleName(),  getLastName());

}

@Override

public  String  toString()  {

return  "Name{"  +

"firstName=’"  +  firstName  +   ’\’’  +

" ,  middleName=’"  +  middleName  +   ’\’’  +

" ,  lastName=’"  +  lastName  +   ’\’’  +

} ’ ;

}

}

package  version3;

import  java .time .LocalDate;

import  java .util .Arrays;

import  java .util .Objects;

/**

*  Class  ResearchPaper  contains  information  about  a  peer -reviewed  research  paper,  containing

*  unique  research  paper  ID,  represented  as  a  String,  title  of  the  paper,  represented  as  a  String,

*  name  of  the  corresponding  authors,  names  of  all  the  authors,  represented  as  data  type  Name,  year

*  the  paper  is  published,  represented  as  LocalData,  venue  (conference,  journal  or  magazine)  where

*  the  paper  has  been  published,  and  the  number  of  citations  that  a  paper  has,  represented  as  an

*  Integer . */

public  class  ResearchPaper  {

private  Integer  paperID;

private  String  title;

private  Name  correspondingAuthor;

private  Name[]  authors;

private  LocalDate  publishingYear;

private  String  publishingVenue;

private  Integer  numCitations;

public  ResearchPaper(Integer  paperID,  String  title,  Name  correspondingAuthor,

Name[]  authors,  LocalDate  publishingYear,  String  publishingVenue,

Integer  numCitations)  {

this .paperID  =  paperID;

this .title  =  title;

this .correspondingAuthor  =  correspondingAuthor;

this .authors  =  authors;

this .publishingYear  =  publishingYear;

this .publishingVenue  =  publishingVenue;

this .numCitations  =  numCitations;

}

public  Integer  getPaperID()  {

return  paperID;

}

public  String  getTitle()  {

return  title;

}

public  Name  getCorrespondingAuthor()  {

return  correspondingAuthor;

}

public  Name[]  getAuthors()  {

return  authors;

}

public  LocalDate  getPublishingYear()  {

return  publishingYear;

}

public  String  getPublishingVenue()  {

return  publishingVenue;

}

public  Integer  getNumCitations()  {

return  numCitations;

}

@Override

public  boolean  equals(Object  o)  {

if  (this  ==  o)  {

return  true;

}

if  (o  ==  null   | |  getClass()   !=  o .getClass())  {

return  false;

}

ResearchPaper  that  =  (ResearchPaper)  o;

return  Objects .equals(paperID,  that .paperID)  &&  Objects .equals(title,

that .title)  &&  Objects .equals(correspondingAuthor,  that .correspondingAuthor) &&  Arrays .equals(authors,  that .authors)  &&  Objects .equals(publishingYear,

that .publishingYear)  &&  Objects .equals(publishingVenue,  that .publishingVenue) &&  Objects .equals(numCitations,  that .numCitations);

}

@Override

public  int  hashCode()  {

int  result  =  Objects .hash(paperID,  title,  correspondingAuthor,  publishingYear,  publishingVenue,

numCitations);

result  =  31  *  result  +  Arrays .hashCode(authors);

return  result;

}

@Override

public  String  toString()  {

return  "ResearchPaper{"  +

"paperID= "  +  paperID  +

" ,  title=’"  +  title  +   ’\’’  +

" ,  correspondingAuthor= "  +  correspondingAuthor  +

" ,  authors= "  +  Arrays .toString(authors)  +

" ,  publishingYear= "  +  publishingYear  +

" ,  publishingVenue=’"  +  publishingVenue  +   ’\’’  +

" ,  numCitations= "  +  numCitations  +

} ’ ;

}

}