原文地址: 简易招聘管理器
Introduction
完成Java应用程序,练习OOP的程序设计方法,实现一个招聘管理器。
Requirement
New York City's hottest new startup Bookface is recruiting new software developers to handle their unprecedented growth! You are attempting to impress Zack Muckerberg with your software development prowess, and it is your job to catalog the applicants. Having received a multitude of applications from newly graduated students and experienced developers alike, it is now your job to implement a system to organize them so that you only select the best possible applicants to help the company grow. Being that you are the hiring manager for one of the world's biggest up-and-coming tech companies, it is important that your system is able to filter out the applicants that are not up to par. Applicants can list up to 3 skills and 3 companies that they have previously worked for, and you are responsible for the implementation of a refined search system that returns specific applicants depending on both the aforementioned criteria and the applicant's GPA.
Problem 1
Write a fully-documented class named Applicant which contains the Company Name (String[]), Applicant Name (String), GPA (double), College (String), and Skills (String[]). Getters and setters should be provided for each variable. Setters should throw the proper exception when given a faulty input (IE: a negative number for GPA). Also include a constructor, an equals() method, a toString() method, and a clone() method for the class. To summarize, the full list of required methods is:
- public Applicant() - constructor (you may also include a constructor with parameters)
- public Object clone() - the return value is a copy of this Applicant object. Any further changes to the copy will not affect the original and vice versa. Note that the return value must be typecast to an Applicant object before it can be used.
- public boolean equals(Object obj) - Returns a value of true if the object that this Applicant is being compared to has the same attributes. Returns false if the attributes are not the same.
- public String toString() - Returns a String representation of the Applicant object. See sample I/O for format.
- getter/setter methods for each variable
Problem 2
Write a fully-documented class named HiringTable which stores a list of Applicant objects in an array. You, the hiring manager, should only be able to insert an Applicant object to the end of the list. Each Applicant is limited to 3 skills and 3 companies both of which should be defined as MAX_SKILLS=3 and MAX_COMPANIES=3. Likewise to the aforementioned variables, the max number of applicants in the table should be set to MAX_APPLICANTS=50. These constant variables should be declared as static and final. In your code, you should avoid using hard-coded values for constants and should instead use defined constants such as MAX_APPLICANTS, MAX_COMPANIES, and MAX_SKILLS.
- public class HiringTable
The HiringTable class implements an abstract data type for a list of Applicants supporting some common operations on such lists.
- public HiringTable()
Constructs an instance of the HiringTable with no Applicant objects in it.
Postcondition:
The HiringTable has been initialized to an empty list of Applicants.
- public int size()
Determines the number of Applicant objects currently in the list.
Preconditions:
The HiringTable has been instantiated.
Returns:
The number of Applicants objects in this HiringTable.
Note:
This method should run in O(1) time.
- public void addApplicant(Applicant newApplicant)
Parameters:
newApplicant - the new Applicant object to add to the list
Preconditions:
This Applicant object has been instantiated and the number of applicants in the HiringTable is less than MAX_APPLICANTS.
Postconditions:
The new Applicant is now inserted at the end of the list.
Throws:
FullTableException
Indicates that there is no more room in the HiringTable for new Applicants.
- public void removeApplicant(String name)
Parameters:
name - the name of the applicant that must be removed
Preconditions:
The HiringTable has been instantiated.
Postconditions:
The Applicant with the name given has been removed from the list. Any Applicant that was in a spot after the removed Applicant are shifted upwards one spot. To put simply, make sure that there are no gaps in the array when removing an applicant.
Throws:
ApplicantNotFoundException
Indications that the applicant with the given name was not found.
- public Applicant getApplicant(String name)
Parameters:
name - name of the Applicant to retrieve.
Preconditions:
The HiringTable object has been instantiated.
Returns:
The Applicant with the corresponding name.
Throws:
ApplicantNotFoundException
Indicates that the applicant with the given name was not found
- public static void refineSearch(HiringTable table, String company, String skill, String college, double GPA)
Prints all the Applicant objects that match the requested criteria.
Parameters:
table - The list of applicants to search in
company - The company must be in the Applicant's application
skill - The skill that must be in the Applicant's application
college - The college that must be in the Applicant's application
GPA - The minimum GPA that must be in the Applicant's application
Preconditions:
The HiringTable object has been instantiated.
Postconditions:
Displays a neatly formatted table of each Applicant filtered from the HiringTable.
- public Object clone()
Creates a copy of this HiringTable. Any changes done on the cloned HiringTable or the original will not affect one another.
Preconditions:
This HiringTable has been instantiated.
Returns:
A copy of this HiringTable object.
- public void printApplicantTable()
Prints a neatly formatted table of each item in the list with its position number as shown in the sample output.
Preconditions:
The HiringTable has been instantiated.
Postconditions:
Displays a neatly formatted table of each Applicant from the HiringTable.
Problem 3
Write a fully-documented class named HiringSystem that is based on the following:
public class HiringSystem
public static void main (String[] args)
The main method runs a menu driven application that first creates an empty HiringTable object. The program then prompts the user for a command in order to execute an operation. Once a command has been chosen, the program may ask the user for additional information if necessary to perform the operation. The operations are defined as follows:
- (A) Add Applicant [Company] [Applicant Name] [GPA] [College] [Skills]
Adds a new applicant onto the end of the list
- (R) Remove Applicant [Applicant Name]
Removes the applicant based on name
- (G) Get applicant [Name]
Displays the information of the applicant based on the name entered
- (P) Print List
Prints all of the applicants in the list
- (RS) Refine Search [Company] [Skill] [College] [GPA]
Returns a list of applicants that have met the search criteria
- (S) Size
Displays the number of applicants in the list
- (B) Backup
Creates a backup of the list in memory
- (CB) Compare Backup
Checks if the current list and the backup are the same
- (RB) Revert Backup
Reverts to the previously backed-up list
- (Q) Quit
Terminates the program
Problem 4
You will need classes to handle the exceptions thrown (see class specifications above for exception classes you need).
Note: You may include additional methods in any class as necessary or as you find convenient.
INPUT FORMAT:
- Each menu operation is entered on its own line and should be case insensitive (i.e. 'q' and 'Q' are the same).
- For the Add Applicant command, if the input information is valid, construct the object accordingly. Otherwise, print an error message and return to the main menu.
- You may assume Strings are at most 25 characters long.
OUTPUT FORMAT:
- Each command should output the result (as shown in sample IO below) after each operation is performed.
- All menu operations must be accompanied by a message indicating what operation was performed and whether or not it was successful.
- All lists must be printed in a nice and tabular form as shown in the sample output. You may use C style formatting as shown in the following example. The example below shows two different ways of displaying the name and address at pre-specified positions 21, 26, 19, and 6 spaces wide. If the '-' flag is given, then it will be left-justified (padding will be on the right), else the region is right-justified. The 's' identifier is for strings, the 'd' identifier is for integers. Giving the additional '0' flag pads an integer with additional zeroes in front.
String name = "Doe Jane";
String address = "32 Bayview Dr.";
String city = "Fishers Island, NY"; int zip = 6390;
System.out.println(String.format("%-21s%-26s%19s%06d", name, address, city, zip));
System.out.printf("%-21s%-26s%19s%06d", name, address, city, zip);
Doe Jane 32 Bayview Dr. Fishers Island, NY 06390
Doe Jane 32 Bayview Dr. Fishers Island, NY 06390
Sample Program Run:
(A) Add Applicant
(R) Remove Applicant
(G) Get Applicant
(P) Print List
(RS) Refine Search
(S) Size
(D) Backup
(CB) Compare Backup
(RB) Revert Backup
(Q) Quit
Please enter a command: A
Enter Applicant Name: Mark Zuck
Enter Applicant GPA: 3.99
Enter Applicant College: Harvard
Enter up to 3 Companies: Facebook
Enter up to 2 Companies: //Empty Line
// Enter empty line to move to next category
Enter up to 3 Skills: Business Management
Enter up to 2 Skills: //Empty Line
Applicant Mark Zuck has been successfully added to the hiring system.
// Print Menu
Please enter a command: A
Enter Applicant Name: Steve Jobs
Enter Applicant GPA: 3.98
Enter Applicant College: De Anza College
Enter up to 3 Companies: Apple
Enter up to 2 Companies: Google
Enter up to 1 Companies: Two Sigma
Enter up to 3 Skills: Ruby on Rails
Enter up to 2 Skills: Java
Enter up to 1 Skills: //Empty Line
Applicant Steve Jobs has been successfully added to the hiring system.
// Print Menu
Please enter a command: A
Enter Applicant Name: Henry White
Enter Applicant GPA: 2.5
Enter Applicant College: NYIT
Enter up to 3 Companies: AirBnb
Enter up to 2 Companies: Facebook
Enter up to 1 Companies: //Empty Line
Enter up to 3 Skills: Javascript
Enter up to 2 Skills: //Empty Line
Applicant Henry White successfully added to the hiring system.
// Print Menu
Please enter a command: P
Company Name Applicant GPA College Skills
--------------------------------------------------------------------------------------------------
Facebook Mark Zuck 3.99 Harvard Business Management
Apple, Google, Two Sigma Steve Jobs 3.98 De Anza College Ruby on Rails, Java
AirBnb, Facebook Henry White 2.50 NYIT Javascript
// Print Menu
Please enter a command: G
Enter Applicant Name: Mark Zuck
Applicant Name: Mark Zuck
Applicant Applying From: Facebook
Applicant GPA: 3.99
Applicant College: Harvard
Applicant Skills: Business Management
Please enter a command: A
Enter Applicant Name: Bob Chen
Enter Applicant GPA: 3.6
Enter Applicant College: Stony Brook
Enter up to 3 Companies: Quora
Enter up to 2 Companies: Google
Enter up to 1 Companies: Twitter
Enter up to 3 Skills: Java
Enter up to 2 Skills: C++
Enter up to 1 Skills: C
Applicant Bob Chen successfully added to the hiring system.
// Print Menu
Please enter a command: S
There are 4 applicants in the hiring system.
// Print Menu
Please enter a command: P
Company Name Applicant GPA College Skills
--------------------------------------------------------------------------------------------------
Facebook Mark Zuck 3.99 Harvard Business Management
Apple, Google, Two Sigma Steve Jobs 3.98 De Anza College Ruby on Rails, Java
AirBnb, Facebook Henry White 2.50 NYIT Javascript
Quora, Google, Twitter Bob Chen 3.60 Stony Brook Java, C++, C
// Print Menu
Please enter a command: RS
Enter a company to filter for: Facebook
Enter a skill to filter for: //Empty Line
Enter a college to filter for: //Empty Line
Enter the minimum GPA to filter for: //Empty Line
Company Name Applicant GPA College Skills
--------------------------------------------------------------------------------------------------
Facebook Mark Zuck 3.99 Harvard Business Management
AirBnb, Facebook Henry White 2.50 NYIT Javascript
// Print Menu
Please enter a command: RS
Enter a company to filter for: Facebook
Enter a skill to filter for: //Empty Line
Enter a college to filter for: //Empty Line
Enter the minimum GPA to filter for: 3.00
Company Name Applicant GPA College Skills
--------------------------------------------------------------------------------------------------
Facebook Mark Zuck 3.99 Harvard Business Management
// Print Menu
Please enter a command: RS
Enter a company to filter for: //Empty Line
Enter a skill to filter for: Java
(本文出自csprojectedu.com,转载请注明出处)