diff --git a/README.md b/README.md index e1b08a4..053cc91 100644 --- a/README.md +++ b/README.md @@ -1,138 +1,84 @@ -# Creative-Cli-Project -## The Mission - -You and your partner are going to **build a Java command-line application** based on a real-world system. - -There is **no step-by-step instruction manual**. - -Instead, you will take everything you’ve learned so far and **design your own solution**. - -Think of this as your opportunity to prove: - -* You can design software -* You can structure Java programs -* You can collaborate with a partner -* You can explain your technical decisions - -Your goal is to build something that **works, is organized, and shows your understanding of Java.** - ---- - -# Theme: EveryDay Appliication - -Your project must represent a **system people use in real life** - -You are encouraged to **get creative and build something interesting.** - ---- - -# Team Structure - -You will work **in pairs**. - -Because everyone recently earned their **Certified Scrum Master certification**, you will organize your work into **three sprint phases**. - -Your README must document what happened in each sprint. - ---- - -# Sprint Documentation - -Your README must include these three sections. - ---- - -## Sprint 1 — The Plan - -Before writing code, explain: - -* What problem your program solves -* What features you want to build -* What classes you expect to create -* How you divided the work between partners - -Think of this as your **project blueprint**. - ---- - -## Sprint 2 — The Build - -Explain: - -* What you actually implemented -* What changed from your original plan -* Challenges you encountered -* How you solved them - -Real software projects **never go exactly as planned** — document your journey. - ---- - -## Sprint 3 — The Reflection - -Explain: - -* What works well in your program -* What you would improve with more time -* What Java concepts you used the most -* What you learned from the experience - ---- - -# Code Explanation Requirement - -Your code must contain **comments explaining your technical decisions**. - -The goal is to show **why you used certain Java concepts**, not just that the code runs. - -Explain things like: - -* Why you created certain classes -* Why you used specific collections -* Why you used loops or conditionals -* Why methods are structured a certain way - -Example: - -```java -// Using ArrayList because the number of tasks can grow dynamically -ArrayList tasks = new ArrayList<>(); - -// Loop used to display all tasks stored in the system -for (String task : tasks) { - System.out.println(task); -} -``` - -Your comments should help someone understand **how your program works and why it was designed that way**. - ---- - -# Technical Expectations - -Your project should demonstrate the core Java skills we have practiced: - -* Classes and Objects -* Constructors -* Methods -* Encapsulation (getters/setters) -* Loops -* Conditional statements -* Collections (`ArrayList`, `HashMap`, etc.) -* User input using `Scanner` -* Clean program organization - -Your application must run **in the command line**. - ---- - -# Final Goal - -This project is about demonstrating that you can: - -* Design software without step-by-step instructions -* Apply Java concepts to a real problem -* Work effectively with a partner -* Explain your code and decisions - -Build something that helps reinfornce knowledge for the final java exa! +# Employee Management System + +A Java console application for basic employee tracking. The program allows users to log in by ID, review employee hours, update hours, add new hires, and view all employee summaries. + +## Sprint 1 - The Plan + +### Problem the Program Solves +Small teams often need a simple way to track employee records and work hours without a full database or web app. This project solves that by providing a lightweight command-line system for employee management tasks. + +### Planned Features +- ID-based login flow +- Menu-driven actions for managers/employees +- View an employee's current hours +- Update employee hours +- Add a new employee with a random 3-digit ID +- Print a list of all employees + +### Planned Classes +- `Person` (abstract base class for shared identity/contact fields) +- `Employee` (extends `Person`, stores hours worked) +- `siteManager` (extends `Person`, tracks employees on site) +- `SiteSystem` (main workflow/menu logic) +- `Main` (application entry point) + +### Work Division Between Partners +- Partner A: Domain model and inheritance structure (`Person`, `Employee`, `siteManager`) +- Partner B: Console flow and feature implementation (`SiteSystem`, menu options, input handling) +- Shared: Testing flows, bug fixes, and output formatting + +## Sprint 2 - The Build + +### What Was Implemented +- Created an OOP structure with inheritance (`Person` -> `Employee` / `siteManager`) +- Built a menu-based system in `SiteSystem` +- Implemented: + - Option 2: lookup employee and display hours + - Option 3: add hours to existing employee total + - Option 4: add new hire and generate random ID (`100-999`) + - Option 5: display all employee summaries +- Added validation messaging such as "Employee ID not found" + +### What Changed from the Original Plan +- Employee lists needed synchronization between manager tracking and the main `people` list +- Print logic was adjusted to use summaries instead of object references +- Input handling was refined to avoid scanner newline issues + +### Challenges Encountered +- New hires were not appearing in all views because they were added to only one list +- Scanner input sequencing (`nextInt()` and `nextLine()`) caused skipped fields +- Incorrect method usage when updating hours (getter vs setter) + +### How Challenges Were Solved +- Added new hires to both relevant collections where needed +- Used proper newline consumption before string input +- Switched to `setHoursWorked(getHoursworked() + hourAdd)` pattern +- Added clearer loop logic and not-found messages + +## Sprint 3 - The Reflection + +### What Works Well +- Clear class separation and inheritance-based design +- Menu options cover core employee management tasks +- Hours update and employee lookup workflows function as expected +- Program compiles and runs as a clean console app + +### What to Improve with More Time +- Replace in-memory lists with persistent storage (file or database) +- Add stronger input validation and exception handling +- Implement role-based permissions (manager vs employee actions) +- Refactor naming/style (`siteManager` -> `SiteManager`) and add unit tests + +### Java Concepts Used Most +- Classes and objects +- Inheritance and abstract classes +- Method overriding +- ArrayLists and loops +- Type checking/casting (`instanceof`) +- User input with `Scanner` + +### What Was Learned +- Planning helps, but implementation details always evolve +- Data consistency between collections matters in real features +- Input handling in console apps requires careful sequencing +- OOP design makes code easier to extend as requirements grow diff --git a/src/main/java/org/codedifferently/Employee.java b/src/main/java/org/codedifferently/Employee.java new file mode 100644 index 0000000..398026d --- /dev/null +++ b/src/main/java/org/codedifferently/Employee.java @@ -0,0 +1,31 @@ +package org.codedifferently; + +// Concrete Person type used for employees whose work hours are tracked. +public class Employee extends Person { + // Running total of employee hours. + private double hoursworked; + + // Builds an employee with profile data plus starting hour balance. + public Employee(int id, String firstname, String lastname, String email, double hoursworked){ + super(id, firstname, lastname, email); + this.hoursworked=hoursworked; + } + + @Override +// Returns a formatted, multi-line summary used by the menu print options. + public String getSummary(){ + return "[Employee]" + " " + getFirstname() + " " + getLastname() + "\n" + + "ID: " + getId() + "\n" + "Hours Worked" + " " + hoursworked; + } + + // Replaces the current hour total with a new total. + public void setHoursWorked(double hoursworked) { + this.hoursworked = hoursworked; + } + + // Returns the current hour total. + public double getHoursworked() { + return hoursworked; + } +} + diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 435139b..99fb723 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/Main.java @@ -4,14 +4,6 @@ // click the icon in the gutter. public class Main { public static void main(String[] args) { - //TIP Press with your caret at the highlighted text - // to see how IntelliJ IDEA suggests fixing it. - System.out.printf("Hello and welcome!"); - - for (int i = 1; i <= 5; i++) { - //TIP Press to start debugging your code. We have set one breakpoint - // for you, but you can always add more by pressing . - System.out.println("i = " + i); + SiteSystem siteSystem = new SiteSystem(); } } -} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/Person.java b/src/main/java/org/codedifferently/Person.java new file mode 100644 index 0000000..e8c00f0 --- /dev/null +++ b/src/main/java/org/codedifferently/Person.java @@ -0,0 +1,56 @@ +package org.codedifferently; + +// Base abstraction for every person record in the system. +// Shared identity/contact fields live here, while child classes define custom summaries. +public abstract class Person { + // Unique identifier used for login/lookup. + private int id; + // Basic profile values shared by all roles. + private String firstname; + private String lastname; + private String email; + + // Constructor initializes all shared Person data at object creation time. + public Person(int id, String firstname, String lastname, String email){ + this.id=id; + this.firstname=firstname; + this.lastname=lastname; + this.email=email; + + } + // Setters allow future updates to profile data. + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public void setId(int id) { + this.id = id; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setEmail(String email) { + this.email = email; + } + // Getters expose read-only access to stored profile values. + public String getLastname() { + return lastname; + } + + public String getFirstname() { + return firstname; + } + + public int getId() { + return id; + } + + public String getEmail() { + return email; + } + + // Each subclass provides its own summary. + public abstract String getSummary(); +} diff --git a/src/main/java/org/codedifferently/SiteSystem.java b/src/main/java/org/codedifferently/SiteSystem.java new file mode 100644 index 0000000..6352175 --- /dev/null +++ b/src/main/java/org/codedifferently/SiteSystem.java @@ -0,0 +1,172 @@ +package org.codedifferently; + + + +import java.util.ArrayList; +import java.util.Random; +import java.util.Scanner; + +// Console workflow class: handles login, menu options, and in-memory employee operations. +public class SiteSystem { + + // Constructor runs the application session loop for this project. + public SiteSystem() { + // Used to generate 3-digit employee IDs for new hires. + Random random = new Random(); + + // Scanner reads user input from console. + Scanner scanner = new Scanner(System.in); + // Primary in-memory list used for login and employee lookups. + ArrayList people = new ArrayList<>(); + + // Seed data for initial testing/demo records. + siteManager Corey = new siteManager(872, "Corey", "Jones", "Cj98@gmail.com", "110 East 28th st Wilmiington De 19802 "); + Employee employee1 = new Employee(872, "Corey", "Jones", "Cj98@gmail.com", 40.23); + Employee employee2 = new Employee(221, "Kiya", "Smith", "Kiysm@icloud.com", 22.42); + + Employee employee3 = new Employee(429, "Kiya", "Smith", "Kiysm@icloud.com", 18.42); + Employee employee4 = new Employee(192, "Jason", "Dozier", "Jdoz@gmail.com", 12.45); + Corey.addemployee(employee3); + Corey.addemployee(employee4); + + people.add(employee1); + people.add(employee2); + people.add(employee3); + people.add(employee4); + + // Session loop continues until caller decides to stop (currently runs continuously). + boolean done = false; + + while (!done) { + + System.out.println("======Welcome to OverSight======"); + System.out.println("\nPlease enter your ID number:"); + + int identry = scanner.nextInt(); + + // Tracks whether the entered ID matched anyone in the system. + boolean found = false; + + for (Person p : people) { + + if (identry == p.getId()) { + + found = true; + + System.out.println("Welcome " + p.getFirstname() + ", what would you like to do today?"); + System.out.println("1. Update your site location"); + System.out.println("2. See employee hours worked"); + System.out.println("3. Update employee hours"); + System.out.println("4. Update new hire"); + System.out.println("5. See all employees"); + int choice = scanner.nextInt(); + + switch (choice) { + + // Placeholder for future location-update feature. + case 1: + System.out.println("Updating site location..."); + scanner.nextLine(); + System.out.println("Please Enter Updated Site location. address, City, state, zipcode format:"); + Corey.setLocation(scanner.nextLine()); + System.out.println("You updated your location to:" + " " + Corey.getLocation()); + break; + + // Looks up one employee by ID and prints current hours. + case 2: + System.out.println("Viewing employee hours..."); + scanner.nextLine(); + System.out.println("Enter employee ID:"); + int checkEmployeeHrs = scanner.nextInt(); + boolean employeeFound = false; + for (Person dex : people) { + if (checkEmployeeHrs == dex.getId() && dex instanceof Employee) { + Employee emp = (Employee) dex; + System.out.println(emp.getFirstname() + " " + emp.getLastname() + + " has " + emp.getHoursworked() + " hours."); + employeeFound = true; + } + } + if (!employeeFound) { + System.out.println("Employee ID not found."); + } + break; + + // Adds entered hours to an existing employee's hour total. + case 3: + System.out.println("Updating employee hours..."); + scanner.nextLine(); + System.out.println("Enter employee ID:"); + int idcheck = scanner.nextInt(); + boolean updated = false; + for (Person index : people) { + if (idcheck == index.getId() && index instanceof Employee) { + Employee emp = (Employee) index; + System.out.println("Enter hours to add:"); + double houradd = scanner.nextDouble(); + + emp.setHoursWorked(emp.getHoursworked() + houradd); + System.out.println(emp.getFirstname() + " " + "now has" + " " + emp.getHoursworked() + " " + "hours."); + updated = true; + break; + } + } + if (!updated) { + System.out.println("Employee ID not found."); + } + break; + + // Creates and stores a new employee from console input. + case 4: + System.out.println("Adding new hire..."); + scanner.nextLine(); + System.out.println("Enter first name:"); + + String firstname = scanner.nextLine(); + System.out.println("Enter last name:"); + + String lastname = scanner.nextLine(); + System.out.println("Enter Email:"); + String email = scanner.nextLine(); + int n = random.nextInt(900) + 100; + Employee employeecreation = new Employee(n, firstname, lastname, email, 0.0); + people.add(employeecreation); + Corey.addemployee(employeecreation); + System.out.println(employeecreation.getSummary()); + break; + + + // Prints summaries for all people currently in memory. + case 5: + for (Person person : people) { + System.out.println(person.getSummary()); + + } + break; + + default: + System.out.println("Invalid option."); + } + + done = promptToExit(scanner); + if (done) { + System.out.println("Goodbye"); + } + + break; + } + } + + if (!found) { + System.out.println("I'm sorry but that isn't a match, please try again."); + } + } + } + + // Prompts once after each action so session flow is consistent across all menu options. + private boolean promptToExit(Scanner scanner) { + System.out.println("If you are finished enter 'done' to exit, to continue enter 'continue'"); + String doneOrContinue = scanner.next(); + return doneOrContinue.equalsIgnoreCase("done"); + } +} diff --git a/src/main/java/org/codedifferently/siteManager.java b/src/main/java/org/codedifferently/siteManager.java new file mode 100644 index 0000000..ba58064 --- /dev/null +++ b/src/main/java/org/codedifferently/siteManager.java @@ -0,0 +1,48 @@ +package org.codedifferently; + +import java.util.ArrayList; + +// Manager role that tracks on-site location and a list of assigned employees. +public class siteManager extends Person{ + // Current location text for this manager. + private String location; + // Employees currently assigned to this manager/site. + private ArrayList employeesonsite; + // Counter used when printing summary details. + private int totalemployees; + + // Initializes manager profile, location, and an empty employee list. + public siteManager(int id, String firstname, String lastname, String email, String location){ + super(id, firstname, lastname, email); + this.location=location; + this.employeesonsite= new ArrayList<>(); + this.totalemployees=totalemployees; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getLocation() { + return location; + } + + // Adds an employee object to the manager's on-site roster. + public void addemployee(Employee employee){ + employeesonsite.add(employee); + } + @Override + // Prints each employee summary and manager details, then returns a total count label. + public String getSummary() { + for (Employee e : employeesonsite) { + ++totalemployees; + System.out.println("\n" + e.getSummary()); + System.out.println("[Site Manager]" + getFirstname() + " " + getLastname() + + "\n" + " Location: " + location); + + } + return "Total employees" + " " + totalemployees; + + } + +}