Using the below code as a starting point please add full functionality. The jobSeeker class is only
Question:
Using the below code as a starting point please add full functionality. The jobSeeker class is only able to apply for a job and check the status of their application. The jobPoster class is able to post positions that will ultimately be stored into the database for approval by the jobManager so that there isn't a improper post. They will provide contact information on how to reach out to display to jobSeeker when the jobSeeker quarries about a job opening, they posted. This data should be pre-saved within the database from when the jobPoster created the job posting originally. The next one is the jobManager this is a pseudo, admin role with access to approve jobs or decline them. This class will require a login to access. All classes require a menu detailing each action and then logic to back up that action. Please altar the Main class to sufficiently test any changes with an example of output of functionality provided if possible.
Main.java
import java.util.Scanner; public class Main { public static void main(String[] args) { // Create Database Database database = new Database(); // Create Job Manager jobManager Bill = new jobManager(); Bill.login("Will contain a email this is filler text", "jobManager"); // Display Job Manager Menu Bill.displayMenu(database); // Process Job Manager Menu Choice processJobManagerMenu(Bill, database); } private static void processJobManagerMenu(jobManager manager, Database database) { Scanner scanner = new Scanner(System.in); try { System.out.println("Job Manager Menu:"); System.out.println("1. Delete Job"); System.out.println("2. Approve/Reject Pending Job"); System.out.println("3. Create Job"); int choice = 0; // Check if there is an integer available for choice if (scanner.hasNextInt()) { choice = scanner.nextInt(); } else { System.out.println("Invalid input. Please enter a valid integer."); return; } switch (choice) { case 1: System.out.print("Enter job ID to delete: "); String jobId = scanner.next(); // Call the deleteJob method with the manager and database manager.deleteJob(database, jobId); break; case 2: // Add your logic for approving/rejecting pending jobs break; case 3: // Add your logic for creating a new job break; default: System.out.println("Invalid choice. Please enter a number between 1 and 3."); } } catch (Exception e) { e.printStackTrace(); } finally { // Close the scanner in the finally block scanner.close(); } }}
Job.java
public class Job { private String JobID; private String Position; private String Description; private String Salary; private JobIDGenerator generator = new JobIDGenerator(); public Job() { this.JobID = generator.generateJobID(); this.Position = ""; this.Description = ""; this.Salary = ""; } public void setPosition(String enteredPosition) { Position = enteredPosition; } public void setDescription(String enteredDescription) { Description = enteredDescription; } public void setSalary(String enteredSalary) { Salary = enteredSalary; } public String getJobID() { return JobID; } public String getSalary() { return Salary; } public String getDescription() { return Description; } public String getPosition() { return Position; } }
Database.java
import java.util.ArrayList; import java.util.Iterator; public class Database { private ArrayList jobs; private ArrayList users; private ArrayList pendingJobs; public Database() { this.jobs = new ArrayList<>(); this.users = new ArrayList<>(); this.pendingJobs = new ArrayList<>(); } public void addJob(Job job) { jobs.add(job); } public void removeJob(Job job) { jobs.remove(job); } public void addUser(user user) { users.add(user); } public void addPendingJob(Job job) { pendingJobs.add(job); } public ArrayList getJobs() { return jobs; } public ArrayList getPendingJobs() { return pendingJobs; } public void displayPendingJobs() { System.out.println("Pending Jobs:"); for (Job job : pendingJobs) { System.out.println("JobID: " + job.getJobID()); // Display other job details as needed } } public void processPendingJob(user user, String jobID, boolean isApproved) { if (user instanceof jobManager) { Iterator iterator = pendingJobs.iterator(); while (iterator.hasNext()) { Job pendingJob = iterator.next(); if (pendingJob.getJobID().equals(jobID)) { if (isApproved) { // Move the job from pendingJobs to jobs jobs.add(pendingJob); System.out.println("Job with JobID " + jobID + " approved and moved to the jobs list."); } else { // Remove the job from pendingJobs iterator.remove(); System.out.println("Job with JobID " + jobID + " not approved and removed from pending jobs list."); } return; } } System.out.println("Job with JobID " + jobID + " not found in the pending jobs list."); } else { System.out.println("Only job managers can approve or reject jobs."); } } }
JobIDGenerator.java
import java.util.HashSet; import java.util.Random; import java.util.Set; public class JobIDGenerator { private Set generatedIds = new HashSet<>(); private Random random = new Random(); public String generateJobID() { int length = random.nextInt(6) + 5; // Generates random length between 5 and 10 inclusive StringBuilder jobIdBuilder = new StringBuilder(); do { jobIdBuilder.setLength(0); // Clear StringBuilder for (int i = 0; i < length; i++) { jobIdBuilder.append(random.nextInt(10)); // Append random digit (0-9) to the JobID } } while (generatedIds.contains(jobIdBuilder.toString())); // Regenerate if ID already exists String jobId = jobIdBuilder.toString(); generatedIds.add(jobId); return jobId; } }
jobManager.java
import java.util.Iterator; import java.util.Scanner; public class jobManager implements user { private boolean isLoggedIn; private String email; private String password; public jobManager() { isLoggedIn = false; this.createLoginCredentials(); } public void createLoginCredentials() { Scanner createscanner = new Scanner(System.in); System.out.print("Enter your email: "); String newEmail = createscanner.nextLine(); System.out.print("Enter your password: "); String newPassword = createscanner.nextLine(); createscanner.close(); this.email = newEmail; this.password = newPassword; } public String getEmail() { return email; } public void login(String userInputEmail, String userInputPassword) { boolean validCredentials = userInputEmail.equals(email) && userInputPassword.equals(password); if (validCredentials) { isLoggedIn = true; System.out.println("LOGGED IN!"); } else { System.out.println("Invalid credentials. Login failed."); } } public void logout() { isLoggedIn = false; } public void deleteJob(Database database, String jobIDToDelete) { if (!isLoggedIn) { System.out.println("You must be logged in to delete jobs"); return; } Iterator iterator = database.getJobs().iterator(); while (iterator.hasNext()) { Job job = iterator.next(); if (job.getJobID().equals(jobIDToDelete)) { iterator.remove(); System.out.println("Job with JobID " + jobIDToDelete + " deleted successfully."); return; } } System.out.println("Job with JobID " + jobIDToDelete + " not found in the list."); } public void approveJob(Database database, String jobIDToApprove, boolean isApproved) { if (!isLoggedIn) { System.out.println("You must be logged in to approve or reject jobs."); return; } Iterator iterator = database.getPendingJobs().iterator(); while (iterator.hasNext()) { Job pendingJob = iterator.next(); if (pendingJob.getJobID().equals(jobIDToApprove)) { // TODO: Display the data of the job for the manager to look at before deciding if (isApproved) { // Move the job from pendingJobs to jobs database.addJob(pendingJob); System.out.println("Job with JobID " + jobIDToApprove + " approved and moved to the jobs list."); } else { // Remove the job from pendingJobs iterator.remove(); System.out.println("Job with JobID " + jobIDToApprove + " not approved and removed from pending jobs list."); } return; } } System.out.println("Job with JobID " + jobIDToApprove + " not found in the pending jobs list."); } public void createJob(Database database) { Scanner scanner = new Scanner(System.in); System.out.print("Enter job position: "); String position = scanner.nextLine(); System.out.print("Enter job description: "); String description = scanner.nextLine(); System.out.print("Enter job salary: "); String salary = scanner.nextLine(); Job newJob = new Job(); newJob.setPosition(position); newJob.setDescription(description); newJob.setSalary(salary); database.addJob(newJob); System.out.println("Job created successfully."); } @Override public void displayMenu(Database database) { System.out.println("Job Manager Menu:"); System.out.println("1. Delete Job"); System.out.println("2. Approve/Reject Pending Job"); System.out.println("3. Create Job"); // Added option for creating a job // Add more menu options as needed } @Override public void processMenuChoice(int choice, Database database) { Scanner scanner = new Scanner(System.in); switch (choice) { case 1: System.out.print("Enter the job ID to delete: "); String jobIDToDelete = scanner.nextLine(); deleteJob(database, jobIDToDelete); break; case 2: System.out.print("Enter the job ID to approve/reject: "); String jobIDToApprove = scanner.nextLine(); System.out.print("Enter 1 to approve or 0 to reject: "); boolean isApproved = scanner.nextInt() == 1; approveJob(database, jobIDToApprove, isApproved); break; case 3: createJob(database); break; // Add more cases for other menu options default: System.out.println("Invalid choice."); } } }
jobPoster.java
import java.util.ArrayList; import java.util.Scanner; public class jobPoster implements user { private boolean isLoggedIn; private String email; private String password; private ArrayList jobsPosted; public jobPoster(String email, String password) { isLoggedIn = false; this.email = email; this.password = password; this.jobsPosted = new ArrayList<>(); } public void createLoginCredentials() { Scanner createscanner = new Scanner(System.in); System.out.print("Enter your email: "); String newEmail = createscanner.nextLine(); System.out.print("Enter your password: "); String newPassword = createscanner.nextLine(); createscanner.close(); this.email = newEmail; this.password = newPassword; } public String getEmail() { return email; } public void login(String userInputEmail, String userInputPassword) { boolean validCredentials = userInputEmail.equals(email) && userInputPassword.equals(password); if (validCredentials) { isLoggedIn = true; System.out.println("LOGGED IN!"); } else { System.out.println("Invalid credentials. Login failed."); } } public void logout() { isLoggedIn = false; } @Override public void displayMenu(Database database) { System.out.println("Job Poster Menu:"); System.out.println("1. Create Job"); System.out.println("2. See All Posted Jobs"); // Add more menu options as needed } @Override public void processMenuChoice(int choice, Database database) { Scanner scanner = new Scanner(System.in); switch (choice) { case 1: createJob(database); break; case 2: seeAllJobs(database); break; // Add more cases for other menu options default: System.out.println("Invalid choice."); } } public void createJob(Database database) { Scanner scanner = new Scanner(System.in); System.out.print("Enter job position: "); String position = scanner.nextLine(); System.out.print("Enter job description: "); String description = scanner.nextLine(); System.out.print("Enter job salary: "); String salary = scanner.nextLine(); Job newJob = new Job(); newJob.setPosition(position); newJob.setDescription(description); newJob.setSalary(salary); database.addPendingJob(newJob); // TODO: Add the job to the pending jobs list System.out.println("Job created successfully. It is now pending approval."); } public void seeAllJobs(Database database) { ArrayList allJobs = database.getJobs(); if (allJobs.isEmpty()) { System.out.println("No jobs posted yet."); } else { System.out.println("All Posted Jobs:"); for (Job job : allJobs) { System.out.println("Job ID: " + job.getJobID()); System.out.println("Position: " + job.getPosition()); System.out.println("Description: " + job.getDescription()); System.out.println("Salary: " + job.getSalary()); System.out.println("----------------------"); } } } }
jobSeeker.java
import java.util.Scanner; import java.util.ArrayList; public class jobSeeker implements user { private boolean isLoggedIn; private String email; private String password; public jobSeeker(String email, String password) { isLoggedIn = false; this.email = email; this.password = password; } public void createLoginCredentials() { Scanner createscanner = new Scanner(System.in); System.out.print("Enter your email: "); String newEmail = createscanner.nextLine(); System.out.print("Enter your password: "); String newPassword = createscanner.nextLine(); createscanner.close(); this.email = newEmail; this.password = newPassword; } public String getEmail() { return email; } public void login(String userInputEmail, String userInputPassword) { boolean validCredentials = userInputEmail.equals(email) && userInputPassword.equals(password); if (validCredentials) { isLoggedIn = true; System.out.println("LOGGED IN!"); } else { System.out.println("Invalid credentials. Login failed."); } } public void logout() { isLoggedIn = false; } @Override public void displayMenu(Database database) { System.out.println("Job Seeker Menu:"); System.out.println("1. Search Jobs"); System.out.println("2. Apply for Job"); // Add more menu options as needed } @Override public void processMenuChoice(int choice, Database database) { Scanner scanner = new Scanner(System.in); switch (choice) { case 1: searchJobs(database); break; case 2: applyForJob(database); break; // Add more cases for other menu options default: System.out.println("Invalid choice."); } } public void searchJobs(Database database) { System.out.println("Available Jobs:"); ArrayList jobs = database.getJobs(); if (jobs.isEmpty()) { System.out.println("No jobs available."); } else { for (Job job : jobs) { System.out.println("Job ID: " + job.getJobID()); System.out.println("Position: " + job.getPosition()); System.out.println("Description: " + job.getDescription()); System.out.println("Salary: " + job.getSalary()); System.out.println("----------------------"); } } } public void applyForJob(Database database) { Scanner scanner = new Scanner(System.in); System.out.print("Enter the Job ID you want to apply for: "); String jobID = scanner.nextLine(); ArrayList jobs = database.getJobs(); for (Job job : jobs) { if (job.getJobID().equals(jobID)) { System.out.println("You have applied for the following job:"); System.out.println("Position: " + job.getPosition()); System.out.println("Description: " + job.getDescription()); System.out.println("Salary: " + job.getSalary()); System.out.println("Application submitted successfully."); return; } } System.out.println("Job with ID " + jobID + " not found."); } }
user.java
public interface user { void login(String userInputEmail, String userinputPassword); void logout(); void displayMenu(Database database); void processMenuChoice(int choice, Database database); }
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill