From 7f9a7546ba80126776ecedf8f8ea2be637f493c2 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Fri, 6 Mar 2026 10:05:36 -0500 Subject: [PATCH 01/12] test --- .idea/copilot.data.migration.ask2agent.xml | 6 ++++++ .idea/misc.xml | 1 - src/main/java/org/codedifferently/Main.java | 8 -------- 3 files changed, 6 insertions(+), 9 deletions(-) create mode 100644 .idea/copilot.data.migration.ask2agent.xml diff --git a/.idea/copilot.data.migration.ask2agent.xml b/.idea/copilot.data.migration.ask2agent.xml new file mode 100644 index 0000000..1f2ea11 --- /dev/null +++ b/.idea/copilot.data.migration.ask2agent.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index fdc35ea..17e9c2e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/Main.java index 435139b..a04bf99 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); - } } } \ No newline at end of file From 4e1686d041f9e0536f455449e6aa9830122f153a Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Fri, 6 Mar 2026 10:33:36 -0500 Subject: [PATCH 02/12] Implemented MainMenu, added Student and Group data, implemented InputHandler --- .../codedifferently/{ => cbtyson}/Main.java | 8 +++- .../codedifferently/cbtyson/data/Group.java | 9 ++++ .../codedifferently/cbtyson/data/Student.java | 10 ++++ .../cbtyson/helpers/InputHandler.java | 48 +++++++++++++++++++ .../cbtyson/menus/MainMenu.java | 48 +++++++++++++++++++ 5 files changed, 122 insertions(+), 1 deletion(-) rename src/main/java/org/codedifferently/{ => cbtyson}/Main.java (55%) create mode 100644 src/main/java/org/codedifferently/cbtyson/data/Group.java create mode 100644 src/main/java/org/codedifferently/cbtyson/data/Student.java create mode 100644 src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java diff --git a/src/main/java/org/codedifferently/Main.java b/src/main/java/org/codedifferently/cbtyson/Main.java similarity index 55% rename from src/main/java/org/codedifferently/Main.java rename to src/main/java/org/codedifferently/cbtyson/Main.java index a04bf99..2a2a513 100644 --- a/src/main/java/org/codedifferently/Main.java +++ b/src/main/java/org/codedifferently/cbtyson/Main.java @@ -1,9 +1,15 @@ -package org.codedifferently; +package org.codedifferently.cbtyson; + +import org.codedifferently.cbtyson.menus.MainMenu; //TIP To Run code, press or // click the icon in the gutter. public class Main { public static void main(String[] args) { + MainMenu mainMenu = new MainMenu(); + mainMenu.promptMainMenu(); + + } } \ No newline at end of file diff --git a/src/main/java/org/codedifferently/cbtyson/data/Group.java b/src/main/java/org/codedifferently/cbtyson/data/Group.java new file mode 100644 index 0000000..656175f --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/data/Group.java @@ -0,0 +1,9 @@ +package org.codedifferently.cbtyson.data; + +import java.util.ArrayList; + +public class Group { + String name; + int size; + ArrayList studentList; +} diff --git a/src/main/java/org/codedifferently/cbtyson/data/Student.java b/src/main/java/org/codedifferently/cbtyson/data/Student.java new file mode 100644 index 0000000..2f5cfd5 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/data/Student.java @@ -0,0 +1,10 @@ +package org.codedifferently.cbtyson.data; + +public class Student { + + public String name; + public int age; + public int gradeLevel; + public float gpa; + +} diff --git a/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java new file mode 100644 index 0000000..bfe2079 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java @@ -0,0 +1,48 @@ +package org.codedifferently.cbtyson.helpers; +import java.util.Scanner; + +public class InputHandler { + + public static int handleIntegerInput() { + Scanner scan = new Scanner(System.in); + int scanInput = 0; + boolean validScanInput = false; + //While loop to make sure user puts in the correct input + while(!validScanInput) { + //Call Scanner methods + try { + //Scanner method to collect input + scanInput = scan.nextInt(); + validScanInput = true; + } + catch (Exception e) { + //If user enters invalid input, the catch block will prevent errors. + System.out.println("Invalid input! Try typing a number instead of a String!"); + scan.next(); + } + } + return scanInput; + } + + public static String handleStringInput() { + Scanner scan = new Scanner(System.in); + String scanInput = ""; + boolean validScanInput = false; + //While loop to make sure user puts in the correct input + while(!validScanInput) { + //Call Scanner methods + try { + //Scanner method to collect input + scanInput = scan.nextLine(); + validScanInput = true; + } + catch (Exception e) { + //If user enters invalid input, the catch block will prevent errors. + System.out.println("Invalid input! Try typing a valid String!"); + scan.next(); + } + } + return scanInput; + } + +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java new file mode 100644 index 0000000..77d3024 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java @@ -0,0 +1,48 @@ +package org.codedifferently.cbtyson.menus; + +import org.codedifferently.cbtyson.helpers.InputHandler; + +public class MainMenu { + + public void promptMainMenu() { + //Group-Differently + //Structured Group Maker + + boolean inMainMenu = true; + while(inMainMenu) { + System.out.println("============================================================="); + System.out.println(); + System.out.println("Welcome to Group Differently!"); + System.out.println("Please take a moment to assign a new group, or add new students!"); + System.out.println(); + System.out.println("============================================================="); + + System.out.println("1. Add new Student"); + System.out.println("2. Generate Group"); + System.out.println("3. View Students/Groups"); + System.out.println("4. Remove Students from Group"); + System.out.println("5. Exit"); + + int inputCode = InputHandler.handleIntegerInput(); + + switch(inputCode) { + case 1: + break; + case 2: + break; + case 3: + break; + case 4: + break; + case 5: + System.out.println("Have a Nice Day!"); + inMainMenu = false; + break; + } + } + + + + + } +} From f2caae6e4f13525f03b2dd07f1947aef3ae9f23f Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Fri, 6 Mar 2026 10:37:18 -0500 Subject: [PATCH 03/12] added menu files --- .../java/org/codedifferently/cbtyson/menus/AddGroupMenu.java | 4 ++++ .../org/codedifferently/cbtyson/menus/AddStudentMenu.java | 4 ++++ .../java/org/codedifferently/cbtyson/menus/RemoveMenu.java | 4 ++++ src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java | 4 ++++ 4 files changed, 16 insertions(+) create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java new file mode 100644 index 0000000..4df71f1 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.menus; + +public class AddGroupMenu { +} diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java new file mode 100644 index 0000000..81fa362 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.menus; + +public class AddStudentMenu { +} diff --git a/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java new file mode 100644 index 0000000..63cbfb8 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.menus; + +public class RemoveMenu { +} diff --git a/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java new file mode 100644 index 0000000..4db08ae --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.menus; + +public class ViewMenu { +} From 023e6dc5c148af05f98068110c39346c424b51e3 Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Fri, 6 Mar 2026 10:58:54 -0500 Subject: [PATCH 04/12] Implemented default students to group, added static groupList --- .../codedifferently/cbtyson/data/Group.java | 25 +++++++++++ .../cbtyson/data/GroupList.java | 33 +++++++++++++++ .../codedifferently/cbtyson/data/Student.java | 41 +++++++++++++++++-- .../cbtyson/menus/MainMenu.java | 26 ++++++++++++ 4 files changed, 122 insertions(+), 3 deletions(-) create mode 100644 src/main/java/org/codedifferently/cbtyson/data/GroupList.java diff --git a/src/main/java/org/codedifferently/cbtyson/data/Group.java b/src/main/java/org/codedifferently/cbtyson/data/Group.java index 656175f..7aeeaa5 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/Group.java +++ b/src/main/java/org/codedifferently/cbtyson/data/Group.java @@ -4,6 +4,31 @@ public class Group { String name; + String groupID; int size; ArrayList studentList; + + + public Group(String name, String groupID, int size, ArrayList studentList) { + this.name = name; + this.groupID = groupID; + this.size = size; + this.studentList = studentList; + } + + public String getName() { + return name; + } + + public ArrayList getStudentList() { + return studentList; + } + + public String getGroupID() { + return groupID; + } + + public int getSize() { + return size; + } } diff --git a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java new file mode 100644 index 0000000..3e06298 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java @@ -0,0 +1,33 @@ +package org.codedifferently.cbtyson.data; + +import java.util.ArrayList; +import java.util.List; + +public class GroupList { + + static ArrayList groups; + + public static List GetGroups() { + return groups; + } + + public static void AddGroup(Group group) { + groups.add(group); + } + + public static void AddStudentToGroup(String groupID,Student student) { + for (Group group : groups) { + if(group.getGroupID().equals(groupID)) { + group.getStudentList().add(student); + } + } + } + + public static void RemoveStudentFromGroup(String groupID, Student student) { + for (Group group : groups) { + if(group.getGroupID().equals(groupID)) { + group.getStudentList().remove(student); + } + } + } +} diff --git a/src/main/java/org/codedifferently/cbtyson/data/Student.java b/src/main/java/org/codedifferently/cbtyson/data/Student.java index 2f5cfd5..c2bb0e5 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/Student.java +++ b/src/main/java/org/codedifferently/cbtyson/data/Student.java @@ -2,9 +2,44 @@ public class Student { - public String name; + public String firstName; + public String lastName; + public String email; + public String studentID; public int age; - public int gradeLevel; - public float gpa; + public double gpa; + + public Student(String firstName, String lastName, String email, String studentID, int age, double gpa) { + this.firstName = firstName; + this.lastName = lastName; + this.email = email; + this.studentID = studentID; + this.age = age; + this.gpa = gpa; + } + + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public int getAge() { + return age; + } + + public String getEmail() { + return email; + } + + public double getGpa() { + return gpa; + } + + public String getStudentID() { + return studentID; + } } diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java index 77d3024..31567a1 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java @@ -1,13 +1,22 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; import org.codedifferently.cbtyson.helpers.InputHandler; +import java.util.ArrayList; + public class MainMenu { public void promptMainMenu() { //Group-Differently //Structured Group Maker + //generate default students + generateDefaultStudents(); + + //main loop for program boolean inMainMenu = true; while(inMainMenu) { System.out.println("============================================================="); @@ -40,9 +49,26 @@ public void promptMainMenu() { break; } } + } + //generates students, and adds them to a group. then adds them into the static groupList field. + void generateDefaultStudents() { + //Make new students + Student glenn = new Student("Glenn", "Tyson", "mrtyson@gmail.com", "31d13d31", 29, 3.6); + Student chris = new Student("Chris", "Bennett", "cbswag@gmail.com", "1920vfvw", 30, 2.0); + Student alex = new Student("Alex", "Trunzo", "vanyllagodzylla@gmail.com", "120-1f1f", 22, 4.0); + Student bobby = new Student("Bobby", "Money", "bigmoney@gmail.com", "19911-wfwefwe", 25, 3.56); + //List of students added to arrayList + ArrayList students1 = new ArrayList<>(); + students1.add(glenn); + students1.add(chris); + students1.add(alex); + students1.add(bobby); + Group group = new Group("Vanylla Godzylla Band", "90121jofrv", 4, students1); + //Add group + GroupList.AddGroup(group); } } From b7a2975666fa5763b5d99fb7cf76b8c974ac6274 Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Fri, 6 Mar 2026 11:01:55 -0500 Subject: [PATCH 05/12] added new arraylist keyword --- src/main/java/org/codedifferently/cbtyson/data/GroupList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java index 3e06298..3242104 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java +++ b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java @@ -5,7 +5,7 @@ public class GroupList { - static ArrayList groups; + static ArrayList groups = new ArrayList<>(); public static List GetGroups() { return groups; From 9ba3b322f897cfc8cec7f7e8cfd99084c3b53aac Mon Sep 17 00:00:00 2001 From: glenntyson Date: Fri, 6 Mar 2026 11:24:06 -0500 Subject: [PATCH 06/12] Implemented code for remove menu and view menu --- .../cbtyson/menus/MainMenu.java | 4 ++ .../cbtyson/menus/RemoveMenu.java | 42 ++++++++++++++++++- .../cbtyson/menus/ViewMenu.java | 29 ++++++++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java index 31567a1..f372ade 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java @@ -40,8 +40,12 @@ public void promptMainMenu() { case 2: break; case 3: + ViewMenu viewMenu = new ViewMenu(); + viewMenu.viewGroups(); break; case 4: + RemoveMenu removeMenu = new RemoveMenu(); + removeMenu.removeStudentFromGroup(); break; case 5: System.out.println("Have a Nice Day!"); diff --git a/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java index 63cbfb8..24d91a5 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java @@ -1,4 +1,44 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.InputHandler; + public class RemoveMenu { -} + + public void removeStudentFromGroup() { + + System.out.println("Enter Group ID:"); + String groupID = InputHandler.handleStringInput(); + + System.out.println("Enter Student ID:"); + String studentID = InputHandler.handleStringInput(); + + for (Group group : GroupList.GetGroups()) { + + if (group.getGroupID().equals(groupID)) { + + Student studentToRemove = null; + + for (Student student : group.getStudentList()) { + if (student.getStudentID().equals(studentID)) { + studentToRemove = student; + break; + } + } + + if (studentToRemove != null) { + group.getStudentList().remove(studentToRemove); + System.out.println("Student removed successfully!"); + } else { + System.out.println("Student not found in this group."); + } + + return; + } + } + + System.out.println("Group not found."); + } +} \ No newline at end of file diff --git a/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java index 4db08ae..f5e198a 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java @@ -1,4 +1,31 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; + public class ViewMenu { -} + + public void viewGroups() { + + if (GroupList.GetGroups().isEmpty()) { + System.out.println("No groups available."); + return; + } + + for (Group group : GroupList.GetGroups()) { + + System.out.println("=================================="); + System.out.println("Group Name: " + group.getName()); + System.out.println("Group ID: " + group.getGroupID()); + System.out.println("Students:"); + + for (Student student : group.getStudentList()) { + System.out.println(student.getFirstName() + " " + student.getLastName() + " | ID: " + student.getStudentID() + " | GPA: " + student.getGpa()); + } + + System.out.println("=================================="); + System.out.println(); + } + } +} \ No newline at end of file From b823ba4430c08f87bb1a1c97a1cd873bc6cf2ae6 Mon Sep 17 00:00:00 2001 From: glenntyson Date: Fri, 6 Mar 2026 11:26:10 -0500 Subject: [PATCH 07/12] .... --- src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java index 24d91a5..d5fa049 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/RemoveMenu.java @@ -39,6 +39,6 @@ public void removeStudentFromGroup() { } } - System.out.println("Group not found."); + System.out.println("Group not found.").; } } \ No newline at end of file From 08410ebc6e7a857c1571aae88a034d1ce292a1d9 Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Fri, 6 Mar 2026 15:30:10 -0500 Subject: [PATCH 08/12] Finished groupMenu, studentMenu --- .../cbtyson/data/GroupList.java | 17 +++++ .../codedifferently/cbtyson/data/Student.java | 6 +- .../cbtyson/helpers/InputHandler.java | 49 +++++++++++++++ .../cbtyson/menus/AddGroupMenu.java | 38 +++++++++++ .../cbtyson/menus/AddStudentMenu.java | 63 +++++++++++++++++++ .../cbtyson/menus/MainMenu.java | 14 +++-- 6 files changed, 180 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java index 3242104..a594d4c 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java +++ b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java @@ -16,18 +16,35 @@ public static void AddGroup(Group group) { } public static void AddStudentToGroup(String groupID,Student student) { + + boolean groupFound = false; + for (Group group : groups) { if(group.getGroupID().equals(groupID)) { + groupFound = true; group.getStudentList().add(student); } } + + if(!groupFound) { + System.out.println("Group not found!"); + } + } public static void RemoveStudentFromGroup(String groupID, Student student) { + + boolean groupFound = false; + for (Group group : groups) { if(group.getGroupID().equals(groupID)) { + groupFound = true; group.getStudentList().remove(student); } } + + if(!groupFound) { + System.out.println("Group not found!"); + } } } diff --git a/src/main/java/org/codedifferently/cbtyson/data/Student.java b/src/main/java/org/codedifferently/cbtyson/data/Student.java index c2bb0e5..4face3e 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/Student.java +++ b/src/main/java/org/codedifferently/cbtyson/data/Student.java @@ -7,10 +7,10 @@ public class Student { public String email; public String studentID; public int age; - public double gpa; + public String gpa; - public Student(String firstName, String lastName, String email, String studentID, int age, double gpa) { + public Student(String firstName, String lastName, String email, String studentID, int age, String gpa) { this.firstName = firstName; this.lastName = lastName; this.email = email; @@ -35,7 +35,7 @@ public String getEmail() { return email; } - public double getGpa() { + public String getGpa() { return gpa; } diff --git a/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java index bfe2079..7c24166 100644 --- a/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java +++ b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java @@ -45,4 +45,53 @@ public static String handleStringInput() { return scanInput; } + public static String handleDoubleInput() { + Scanner scan = new Scanner(System.in); + String scanInput = ""; + boolean validScanInput = false; + //While loop to make sure user puts in the correct input + while(!validScanInput) { + //Call Scanner methods + try { + //Scanner method to collect input + scanInput = scan.nextLine(); + validScanInput = true; + } + catch (Exception e) { + //If user enters invalid input, the catch block will prevent errors. + System.out.println("Invalid input! Try typing a valid String!"); + scan.next(); + } + } + return String.format(".%2f", scanInput); + } + + public static String handleYesNoInput() { + Scanner scan = new Scanner(System.in); + String scanInput = ""; + boolean validScanInput = false; + //While loop to make sure user puts in the correct input + while(!validScanInput) { + //Call Scanner methods + try { + //Scanner method to collect input + + scanInput = scan.nextLine(); + + if(scanInput.toLowerCase().equals("y") || scanInput.toLowerCase().equals("n")) { + validScanInput = true; + } + else { + System.out.println("Yes (y) or no (n) only!!"); + } + } + catch (Exception e) { + //If user enters invalid input, the catch block will prevent errors. + System.out.println("Invalid input! Try typing a valid String!"); + scan.next(); + } + } + return scanInput; + } + } \ No newline at end of file diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java index 4df71f1..c17d9d0 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java @@ -1,4 +1,42 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.InputHandler; + +import java.util.ArrayList; +import java.util.UUID; + public class AddGroupMenu { + + public void promptGroupMenu() { + + boolean inGroupMenu = true; + + while(inGroupMenu) { + System.out.println("Enter your Group Name:"); + String name = InputHandler.handleStringInput(); + + System.out.println("How big is your group? "); + int groupSize = InputHandler.handleIntegerInput(); + + // Generate a new UUID object + String groupID = UUID.randomUUID().toString(); + groupID = groupID.substring(0,6); + + Group group = new Group(name, groupID, groupSize, new ArrayList()); + + System.out.println(); + + //Add new Group to List + GroupList.AddGroup(group); + + System.out.println("Continue adding groups? (y/n)"); + String answer = InputHandler.handleYesNoInput(); + if(answer.equals("n")) { + inGroupMenu = false; + } + } + } } diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java index 81fa362..d521e5f 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java @@ -1,4 +1,67 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.InputHandler; + +import java.util.UUID; + public class AddStudentMenu { + + public void promptAddStudentMenu() { + + System.out.println("============================================================="); + System.out.println(); + System.out.println("Add Student Menu:"); + System.out.println("Lets add some students!"); + System.out.println(); + System.out.println("============================================================="); + + boolean inStudentMenu = true; + + while (inStudentMenu) { + + System.out.println("Enter their First Name: "); + String firstName = InputHandler.handleStringInput(); + + System.out.println("Enter their Last Name: "); + String lastName = InputHandler.handleStringInput(); + + System.out.println("Enter their Email: "); + String email = InputHandler.handleStringInput(); + + System.out.println("Enter their Age: "); + int age = InputHandler.handleIntegerInput(); + + System.out.println("Enter their GPA: "); + String gpa = InputHandler.handleDoubleInput(); + + // Generate a new UUID object + String studentID = UUID.randomUUID().toString(); + studentID = studentID.substring(0,6); + + Student student = new Student(firstName, lastName, email, studentID, age, gpa); + + System.out.println(); + System.out.println("Which group is this new student going to?"); + System.out.println("Enter the Group ID here:"); + + //Actually add student to group + String groupID = InputHandler.handleStringInput(); + GroupList.AddStudentToGroup(groupID, student); + + System.out.println(); + System.out.println("Make another one? (y/n)"); + System.out.println("========================================="); + + String answerStr = InputHandler.handleYesNoInput(); + if(answerStr.equals("n")) { + inStudentMenu = false; + } + + } + + } + + } diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java index f372ade..0dd604d 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java @@ -16,6 +16,10 @@ public void promptMainMenu() { //generate default students generateDefaultStudents(); + //Menus + AddGroupMenu addGroupMenu = new AddGroupMenu(); + AddStudentMenu addStudentMenu = new AddStudentMenu(); + //main loop for program boolean inMainMenu = true; while(inMainMenu) { @@ -36,8 +40,10 @@ public void promptMainMenu() { switch(inputCode) { case 1: + addStudentMenu.promptAddStudentMenu(); break; case 2: + addGroupMenu.promptGroupMenu(); break; case 3: ViewMenu viewMenu = new ViewMenu(); @@ -58,10 +64,10 @@ public void promptMainMenu() { //generates students, and adds them to a group. then adds them into the static groupList field. void generateDefaultStudents() { //Make new students - Student glenn = new Student("Glenn", "Tyson", "mrtyson@gmail.com", "31d13d31", 29, 3.6); - Student chris = new Student("Chris", "Bennett", "cbswag@gmail.com", "1920vfvw", 30, 2.0); - Student alex = new Student("Alex", "Trunzo", "vanyllagodzylla@gmail.com", "120-1f1f", 22, 4.0); - Student bobby = new Student("Bobby", "Money", "bigmoney@gmail.com", "19911-wfwefwe", 25, 3.56); + Student glenn = new Student("Glenn", "Tyson", "mrtyson@gmail.com", "31d13d31", 29, "3.6"); + Student chris = new Student("Chris", "Bennett", "cbswag@gmail.com", "1920vfvw", 30, "2.0"); + Student alex = new Student("Alex", "Trunzo", "vanyllagodzylla@gmail.com", "120-1f1f", 22, "4.0"); + Student bobby = new Student("Bobby", "Money", "bigmoney@gmail.com", "19911-wfwefwe", 25, "3.56"); //List of students added to arrayList ArrayList students1 = new ArrayList<>(); From e16e4efa141408c991c221b428a8a72489bd5c09 Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Sun, 8 Mar 2026 14:24:11 -0400 Subject: [PATCH 09/12] feat: Added move functionality, random shuffle functionality, fixed issue with students not being added to groups --- .../org/codedifferently/cbtyson/helpers/GroupRandomizer.java | 4 ++++ .../org/codedifferently/cbtyson/menus/MoveStudentMenu.java | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java create mode 100644 src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java diff --git a/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java b/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java new file mode 100644 index 0000000..8fb0bb6 --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.helpers; + +public class GroupRandomizer { +} diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java new file mode 100644 index 0000000..0e011bd --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java @@ -0,0 +1,4 @@ +package org.codedifferently.cbtyson.menus; + +public class MoveStudentMenu { +} From 4f887c3e99388bd40c8ec6b88992720236df4753 Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Sun, 8 Mar 2026 20:00:45 -0400 Subject: [PATCH 10/12] commiting to main again --- .../codedifferently/cbtyson/data/Group.java | 8 +- .../cbtyson/data/GroupList.java | 61 +++++++++++++- .../codedifferently/cbtyson/data/Student.java | 6 +- .../cbtyson/helpers/GroupRandomizer.java | 81 +++++++++++++++++++ .../cbtyson/helpers/InputHandler.java | 10 +-- .../cbtyson/menus/AddGroupMenu.java | 44 +++++++++- .../cbtyson/menus/AddStudentMenu.java | 36 +++++++-- .../cbtyson/menus/MainMenu.java | 26 ++++-- .../cbtyson/menus/MoveStudentMenu.java | 38 +++++++++ .../cbtyson/menus/ViewMenu.java | 4 + 10 files changed, 276 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/codedifferently/cbtyson/data/Group.java b/src/main/java/org/codedifferently/cbtyson/data/Group.java index 7aeeaa5..a89b923 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/Group.java +++ b/src/main/java/org/codedifferently/cbtyson/data/Group.java @@ -5,14 +5,12 @@ public class Group { String name; String groupID; - int size; ArrayList studentList; - public Group(String name, String groupID, int size, ArrayList studentList) { + public Group(String name, String groupID, ArrayList studentList) { this.name = name; this.groupID = groupID; - this.size = size; this.studentList = studentList; } @@ -27,8 +25,4 @@ public ArrayList getStudentList() { public String getGroupID() { return groupID; } - - public int getSize() { - return size; - } } diff --git a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java index a594d4c..9562362 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/GroupList.java +++ b/src/main/java/org/codedifferently/cbtyson/data/GroupList.java @@ -15,7 +15,7 @@ public static void AddGroup(Group group) { groups.add(group); } - public static void AddStudentToGroup(String groupID,Student student) { + public static boolean AddStudentToGroup(String groupID,Student student) { boolean groupFound = false; @@ -30,21 +30,74 @@ public static void AddStudentToGroup(String groupID,Student student) { System.out.println("Group not found!"); } + return groupFound; + } - public static void RemoveStudentFromGroup(String groupID, Student student) { + public static boolean RemoveStudentFromGroup(String groupID, String studentID) { boolean groupFound = false; + boolean studentFound = false; for (Group group : groups) { if(group.getGroupID().equals(groupID)) { groupFound = true; - group.getStudentList().remove(student); + for(Student student : group.getStudentList()) { + if(student.getStudentID().equals(studentID)) { + studentFound = true; + group.getStudentList().remove(student); + return true; + } + } + } } + if(!studentFound && groupFound) { + System.out.println("Student ID not found!"); + } + if(!groupFound) { - System.out.println("Group not found!"); + System.out.println("Group ID not found!"); + } + return false; + } + + public static Student GetStudentFromGroup(String groupID, String studentID) { + boolean groupFound = false; + boolean studentFound = false; + + for (Group group : groups) { + if(group.getGroupID().equals(groupID)) { + groupFound = true; + for(Student student : group.getStudentList()) { + if(student.getStudentID().equals(studentID)) { + studentFound = true; + return student; + } + } + + } + } + + if(!studentFound && groupFound) { + System.out.println("Student ID not found!"); + } + + if(!groupFound) { + System.out.println("Group ID not found!"); + } + return null; + } + + public static String GetGroupIDFromStudentID(String studentID) { + for(Group group : groups) { + for(Student student : group.getStudentList()) { + if(student.getStudentID().equals(studentID)) { + return group.getGroupID(); + } + } } + return null; } } diff --git a/src/main/java/org/codedifferently/cbtyson/data/Student.java b/src/main/java/org/codedifferently/cbtyson/data/Student.java index 4face3e..c2bb0e5 100644 --- a/src/main/java/org/codedifferently/cbtyson/data/Student.java +++ b/src/main/java/org/codedifferently/cbtyson/data/Student.java @@ -7,10 +7,10 @@ public class Student { public String email; public String studentID; public int age; - public String gpa; + public double gpa; - public Student(String firstName, String lastName, String email, String studentID, int age, String gpa) { + public Student(String firstName, String lastName, String email, String studentID, int age, double gpa) { this.firstName = firstName; this.lastName = lastName; this.email = email; @@ -35,7 +35,7 @@ public String getEmail() { return email; } - public String getGpa() { + public double getGpa() { return gpa; } diff --git a/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java b/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java index 8fb0bb6..e5b72fc 100644 --- a/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java +++ b/src/main/java/org/codedifferently/cbtyson/helpers/GroupRandomizer.java @@ -1,4 +1,85 @@ package org.codedifferently.cbtyson.helpers; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Scanner; + + public class GroupRandomizer { + public static void randomizeStudentsIntoGroups(ArrayList allStudents, int groupSize) { + List groups = GroupList.GetGroups(); + + if (groups.isEmpty()) { + System.out.println("No groups exist. Please add groups first."); + return; + } + if (allStudents == null || allStudents.isEmpty()) { + System.out.println("No students to assign."); + return; + } + + // Clear existing students from all groups + for (Group group : groups) { + group.getStudentList().clear(); + } + + // Shuffle a copy of the student list + ArrayList shuffled = new ArrayList<>(allStudents); + Collections.shuffle(shuffled); + + // Determine how many groups we need based on desired group size + int numGroupsNeeded = (int) Math.ceil((double) shuffled.size() / groupSize); + + if (numGroupsNeeded > groups.size()) { + System.out.println("Warning: Not enough groups for group size of " + groupSize + + ". Need " + numGroupsNeeded + " but only have " + groups.size() + + ". Some groups will be larger than requested."); + } + + // Assign students round-robin across available groups + for (int i = 0; i < shuffled.size(); i++) { + int groupIndex = i % groups.size(); + groups.get(groupIndex).getStudentList().add(shuffled.get(i)); + } + + System.out.println("Students assigned! Group breakdown:"); + for (Group g : groups) { + System.out.println(" " + g.getName() + ": " + g.getStudentList().size() + " students"); + } + } + + public static void randomizeStudentsIntoGroupsInteractive(ArrayList allStudents) { + Scanner scanner = new Scanner(System.in); + System.out.print("Enter desired group size: "); + + while (!scanner.hasNextInt()) { + System.out.print("Invalid input. Enter a number: "); + scanner.next(); + } + + int groupSize = scanner.nextInt(); + + if (groupSize <= 0) { + System.out.println("Group size must be at least 1."); + return; + } + + randomizeStudentsIntoGroups(allStudents, groupSize); + } + + public static void randomizeGroups() { + ArrayList studentList = new ArrayList<>(); + + for (Group group : GroupList.GetGroups()) { + for(Student student : group.getStudentList()) { + studentList.add(student); + } + } + randomizeStudentsIntoGroupsInteractive(studentList); + } } diff --git a/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java index 7c24166..92529ae 100644 --- a/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java +++ b/src/main/java/org/codedifferently/cbtyson/helpers/InputHandler.java @@ -45,25 +45,25 @@ public static String handleStringInput() { return scanInput; } - public static String handleDoubleInput() { + public static Double handleDoubleInput() { Scanner scan = new Scanner(System.in); - String scanInput = ""; + double scanInput = 0; boolean validScanInput = false; //While loop to make sure user puts in the correct input while(!validScanInput) { //Call Scanner methods try { //Scanner method to collect input - scanInput = scan.nextLine(); + scanInput = scan.nextDouble(); validScanInput = true; } catch (Exception e) { //If user enters invalid input, the catch block will prevent errors. - System.out.println("Invalid input! Try typing a valid String!"); + System.out.println("Invalid input! Try typing a valid Double!"); scan.next(); } } - return String.format(".%2f", scanInput); + return scanInput; } public static String handleYesNoInput() { diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java index c17d9d0..c4333e9 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddGroupMenu.java @@ -6,6 +6,7 @@ import org.codedifferently.cbtyson.helpers.InputHandler; import java.util.ArrayList; +import java.util.List; import java.util.UUID; public class AddGroupMenu { @@ -18,14 +19,14 @@ public void promptGroupMenu() { System.out.println("Enter your Group Name:"); String name = InputHandler.handleStringInput(); - System.out.println("How big is your group? "); - int groupSize = InputHandler.handleIntegerInput(); + // System.out.println("How big is your group? "); + // int groupSize = InputHandler.handleIntegerInput(); // Generate a new UUID object String groupID = UUID.randomUUID().toString(); groupID = groupID.substring(0,6); - Group group = new Group(name, groupID, groupSize, new ArrayList()); + Group group = new Group(name, groupID, new ArrayList()); System.out.println(); @@ -39,4 +40,41 @@ public void promptGroupMenu() { } } } + + public void promptGroupMenu(Student student) { + boolean inGroupMenu = true; + boolean addedStudent = false; + + while(inGroupMenu) { + System.out.println("Enter your new Group Name:"); + String name = InputHandler.handleStringInput(); + + //System.out.println("How big is your group? "); + //int groupSize = InputHandler.handleIntegerInput(); + + // Generate a new UUID object + String groupID = UUID.randomUUID().toString(); + groupID = groupID.substring(0,6); + + //add student to studentList here, only diff in overloaded method + ArrayList studentList = new ArrayList<>(); + if(!addedStudent) studentList.add(student); + addedStudent = true; + + Group group = new Group(name, groupID, studentList); + + System.out.println(); + + //Add new Group to List + GroupList.AddGroup(group); + System.out.println("The " + group.getName() + " has been made! ID: " + group.getGroupID()); + + System.out.println("Continue adding groups? (y/n)"); + System.out.println("==================================="); + String answer = InputHandler.handleYesNoInput(); + if(answer.equals("n")) { + inGroupMenu = false; + } + } + } } diff --git a/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java index d521e5f..4058707 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/AddStudentMenu.java @@ -34,7 +34,7 @@ public void promptAddStudentMenu() { int age = InputHandler.handleIntegerInput(); System.out.println("Enter their GPA: "); - String gpa = InputHandler.handleDoubleInput(); + double gpa = InputHandler.handleDoubleInput(); // Generate a new UUID object String studentID = UUID.randomUUID().toString(); @@ -42,16 +42,36 @@ public void promptAddStudentMenu() { Student student = new Student(firstName, lastName, email, studentID, age, gpa); - System.out.println(); - System.out.println("Which group is this new student going to?"); - System.out.println("Enter the Group ID here:"); - //Actually add student to group - String groupID = InputHandler.handleStringInput(); - GroupList.AddStudentToGroup(groupID, student); + boolean studentAddedToGroup = false; + + while(!studentAddedToGroup) { + System.out.println(); + System.out.println("Which group is this new student going to?"); + System.out.println("Enter the Group ID here:"); + + //Actually add student to group + String groupID = InputHandler.handleStringInput(); + boolean hasAddedStudent = GroupList.AddStudentToGroup(groupID, student); + + + if(!hasAddedStudent) { + System.out.println("What you like to create a new Group to add this student to? (y/n)"); + System.out.println("============================================================="); + String answerStr = InputHandler.handleYesNoInput(); + if (answerStr.equals("y")) { + AddGroupMenu addGroupMenu = new AddGroupMenu(); + addGroupMenu.promptGroupMenu(student); + studentAddedToGroup = true; + } + } + else { + studentAddedToGroup = true; + } + } System.out.println(); - System.out.println("Make another one? (y/n)"); + System.out.println("Continue adding students? (y/n)"); System.out.println("========================================="); String answerStr = InputHandler.handleYesNoInput(); diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java index 0dd604d..12d7d5e 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/MainMenu.java @@ -3,6 +3,7 @@ import org.codedifferently.cbtyson.data.Group; import org.codedifferently.cbtyson.data.GroupList; import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.GroupRandomizer; import org.codedifferently.cbtyson.helpers.InputHandler; import java.util.ArrayList; @@ -33,8 +34,10 @@ public void promptMainMenu() { System.out.println("1. Add new Student"); System.out.println("2. Generate Group"); System.out.println("3. View Students/Groups"); - System.out.println("4. Remove Students from Group"); - System.out.println("5. Exit"); + System.out.println("4. Move Students across Groups."); + System.out.println("5. Remove Students from Group"); + System.out.println("6. Randomize Groups"); + System.out.println("7. Exit"); int inputCode = InputHandler.handleIntegerInput(); @@ -50,10 +53,17 @@ public void promptMainMenu() { viewMenu.viewGroups(); break; case 4: + MoveStudentMenu moveMenu = new MoveStudentMenu(); + moveMenu.moveGroups(); + break; + case 5: RemoveMenu removeMenu = new RemoveMenu(); removeMenu.removeStudentFromGroup(); break; - case 5: + case 6: + GroupRandomizer.randomizeGroups(); + break; + case 7: System.out.println("Have a Nice Day!"); inMainMenu = false; break; @@ -64,10 +74,10 @@ public void promptMainMenu() { //generates students, and adds them to a group. then adds them into the static groupList field. void generateDefaultStudents() { //Make new students - Student glenn = new Student("Glenn", "Tyson", "mrtyson@gmail.com", "31d13d31", 29, "3.6"); - Student chris = new Student("Chris", "Bennett", "cbswag@gmail.com", "1920vfvw", 30, "2.0"); - Student alex = new Student("Alex", "Trunzo", "vanyllagodzylla@gmail.com", "120-1f1f", 22, "4.0"); - Student bobby = new Student("Bobby", "Money", "bigmoney@gmail.com", "19911-wfwefwe", 25, "3.56"); + Student glenn = new Student("Glenn", "Tyson", "mrtyson@gmail.com", "31d13de", 29, 3.6); + Student chris = new Student("Chris", "Bennett", "cbswag@gmail.com", "1920vfa", 30, 2.0); + Student alex = new Student("Alex", "Trunzo", "vanyllagodzylla@gmail.com", "120-1fd", 22, 4.0); + Student bobby = new Student("Bobby", "Money", "bigmoney@gmail.com", "19911-f", 25, 3.56); //List of students added to arrayList ArrayList students1 = new ArrayList<>(); @@ -76,7 +86,7 @@ void generateDefaultStudents() { students1.add(alex); students1.add(bobby); - Group group = new Group("Vanylla Godzylla Band", "90121jofrv", 4, students1); + Group group = new Group("Vanylla Godzylla Band", "90121j", students1); //Add group GroupList.AddGroup(group); diff --git a/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java index 0e011bd..2f556ae 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/MoveStudentMenu.java @@ -1,4 +1,42 @@ package org.codedifferently.cbtyson.menus; +import org.codedifferently.cbtyson.data.Group; +import org.codedifferently.cbtyson.data.GroupList; +import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.InputHandler; + public class MoveStudentMenu { + + public void moveGroups() { + + System.out.println("Enter Student ID to move:"); + System.out.println("============================="); + + String studentID = InputHandler.handleStringInput(); + + System.out.println("Enter Group ID to move into:"); + String groupID = InputHandler.handleStringInput(); + + + //Get old GroupID that student used to be in + String oldGroupID = GroupList.GetGroupIDFromStudentID(studentID); + + //Get reference to student to be moved. + Student movedStudent = GroupList.GetStudentFromGroup(oldGroupID, studentID); + + //Remove them from old group + boolean removeResult = GroupList.RemoveStudentFromGroup(oldGroupID, studentID); + + if(removeResult) { + //Then add them to new group if remove was successful + boolean result = GroupList.AddStudentToGroup(groupID, movedStudent); + + if(result) System.out.println("Moved Students successfully!"); + } + else { + System.out.println("Removing student from previous group has failed!!"); + } + + } + } diff --git a/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java index f5e198a..e5f604f 100644 --- a/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java +++ b/src/main/java/org/codedifferently/cbtyson/menus/ViewMenu.java @@ -3,6 +3,7 @@ import org.codedifferently.cbtyson.data.Group; import org.codedifferently.cbtyson.data.GroupList; import org.codedifferently.cbtyson.data.Student; +import org.codedifferently.cbtyson.helpers.InputHandler; public class ViewMenu { @@ -27,5 +28,8 @@ public void viewGroups() { System.out.println("=================================="); System.out.println(); } + System.out.println("Press anything to continue"); + System.out.println("=============================="); + InputHandler.handleStringInput(); } } \ No newline at end of file From 7d04fd5e9ed1f8719105d38e89c6559cc32659af Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Tue, 10 Mar 2026 13:32:49 -0400 Subject: [PATCH 11/12] updated README.md --- .../org/codedifferently/cbtyson/README.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/main/java/org/codedifferently/cbtyson/README.md diff --git a/src/main/java/org/codedifferently/cbtyson/README.md b/src/main/java/org/codedifferently/cbtyson/README.md new file mode 100644 index 0000000..0a0443d --- /dev/null +++ b/src/main/java/org/codedifferently/cbtyson/README.md @@ -0,0 +1,75 @@ +# Group Differently + +Group Differently is a simple application for organizing students into groups and managing team assignments efficiently. The program allows users to create students and groups, assign students to groups, shuffle group assignments based on preferred team sizes, and move students between groups when adjustments are needed. + +This tool is designed for scenarios such as classroom team assignments, project group organization, or any situation where students need to be distributed across groups in a flexible way. + +--- + +## Features + +The application provides the following core functionality: + +1. **Add Student** + Create a new student with the following attributes: + - Student ID + - First Name + - Last Name + - Email + - Age + - GPA + +2. **Add Group** + Create a group with: + - Group ID + - Group Name + +3. **View Groups and Students** + View all groups along with the students currently assigned to them. + +4. **Move Students Between Groups** + Transfer a student from one group to another using their Student ID and Group ID. + +5. **Remove Student From Group** + Remove a student from their current group assignment. + +6. **Shuffle Groups by Team Size** + Automatically distribute all students into groups based on a **user-defined team size**. + The program attempts to balance groups as evenly as possible while respecting the preferred team size. + +7. **Exit Program** + Safely close the application. + +--- + +## Data Structure + +### Student + +Each student contains the following information: + +| Field | Description | +|------|-------------| +| ID | Unique identifier for the student | +| First Name | Student's first name | +| Last Name | Student's last name | +| Email | Contact email | +| Age | Student age | +| GPA | Student grade point average | + +### Group + +Each group contains: + +| Field | Description | +|------|-------------| +| ID | Unique identifier for the group | +| Name | Name of the group | + +Group and student **IDs are used as the primary lookup mechanism** throughout the program for searching, assigning, and moving records. + +--- + +## Program Workflow + +When the application starts, the user is presented with a menu of available actions. From 1c2569b755e14fe616a80de59b403407864c10ff Mon Sep 17 00:00:00 2001 From: BennettDeveloper Date: Tue, 10 Mar 2026 13:38:10 -0400 Subject: [PATCH 12/12] fixed README.md structure --- .../org/codedifferently/cbtyson/README.md | 259 ++++++++++++++---- 1 file changed, 212 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/codedifferently/cbtyson/README.md b/src/main/java/org/codedifferently/cbtyson/README.md index 0a0443d..ddbfdce 100644 --- a/src/main/java/org/codedifferently/cbtyson/README.md +++ b/src/main/java/org/codedifferently/cbtyson/README.md @@ -1,75 +1,240 @@ # Group Differently +## The Mission -Group Differently is a simple application for organizing students into groups and managing team assignments efficiently. The program allows users to create students and groups, assign students to groups, shuffle group assignments based on preferred team sizes, and move students between groups when adjustments are needed. +Group Differently is a **Java command-line application** designed to help organize students into groups efficiently. -This tool is designed for scenarios such as classroom team assignments, project group organization, or any situation where students need to be distributed across groups in a flexible way. +The goal of this program is to simulate a real-world classroom scenario where instructors or organizers need to: + +- Create and manage students +- Create groups +- Assign students to groups +- Shuffle students across groups +- Move students between groups when adjustments are needed + +Instead of manually organizing groups, this application allows users to manage and restructure teams quickly using simple command-line controls. + +This project demonstrates our ability to: + +* Design software systems +* Structure Java programs effectively +* Apply object-oriented programming concepts +* Collaborate with a partner using Agile principles +* Explain our technical decisions through documentation and comments --- -## Features +# Theme: Everyday Application -The application provides the following core functionality: +Group Differently represents a **real-world system used in classrooms, training programs, and team-based environments**. -1. **Add Student** - Create a new student with the following attributes: - - Student ID - - First Name - - Last Name - - Email - - Age - - GPA +Teachers, instructors, or team leaders often need to divide people into balanced groups. This application simplifies that process by allowing users to organize and shuffle group assignments automatically while still allowing manual adjustments when necessary. -2. **Add Group** - Create a group with: - - Group ID - - Group Name +--- -3. **View Groups and Students** - View all groups along with the students currently assigned to them. +# Team Structure -4. **Move Students Between Groups** - Transfer a student from one group to another using their Student ID and Group ID. +This project was developed **in pairs**. -5. **Remove Student From Group** - Remove a student from their current group assignment. +Using our **Certified Scrum Master knowledge**, we organized development into **three sprint phases**. -6. **Shuffle Groups by Team Size** - Automatically distribute all students into groups based on a **user-defined team size**. - The program attempts to balance groups as evenly as possible while respecting the preferred team size. +Each sprint allowed us to progressively design, implement, and evaluate our system. -7. **Exit Program** - Safely close the application. +--- + +# Sprint Documentation --- -## Data Structure +## Sprint 1 — The Plan + +Before writing code, we planned the structure of the system. + +### Problem the Program Solves + +Instructors often need to divide students into groups for: + +- Projects +- Discussions +- Lab assignments +- Team activities + +Manually organizing groups can be time-consuming, especially when groups must be balanced or frequently adjusted. + +Group Differently provides a simple system for managing students and distributing them into groups automatically or manually. + +### Planned Features + +We planned the following core features: + +1. Add Student +2. Add Group +3. View Groups and Students +4. Move students from one group to another +5. Remove a student from a group +6. Shuffle students into groups based on a preferred team size +7. Exit the program + +### Expected Classes + +We expected to create several classes to organize the program: -### Student +**Student** -Each student contains the following information: +Stores student information including: -| Field | Description | -|------|-------------| -| ID | Unique identifier for the student | -| First Name | Student's first name | -| Last Name | Student's last name | -| Email | Contact email | -| Age | Student age | -| GPA | Student grade point average | +- ID +- First name +- Last name +- Email +- Age +- GPA -### Group +**Group** -Each group contains: +Represents a group with: -| Field | Description | -|------|-------------| -| ID | Unique identifier for the group | -| Name | Name of the group | +- Group ID +- Group name +- A list of students assigned to the group -Group and student **IDs are used as the primary lookup mechanism** throughout the program for searching, assigning, and moving records. +**Main / Application Class** + +Handles: + +- User input +- Menu navigation +- Program execution + +**Manager / Controller Class (optional)** + +Responsible for managing collections of students and groups. + +### Work Division + +Our team divided the work so both partners contributed to different parts of the system, including: + +- Designing the data structures +- Implementing student and group classes +- Implementing menu functionality +- Implementing shuffle and group management logic +- Testing program behavior --- -## Program Workflow +## Sprint 2 — The Build + +During this phase we implemented the core functionality of the program. + +### Implemented Features + +The final program allows users to: + +1. **Add Student** + +Users can create students with: + +- ID +- First Name +- Last Name +- Email +- Age +- GPA + +2. **Add Group** + +Users can create groups with: + +- Group ID +- Group name + +3. **View Groups and Students** + +Users can display all groups and the students assigned to them. + +4. **Move Student Between Groups** + +Students can be transferred from one group to another using their **Student ID**. + +5. **Remove Student From Group** + +Students can be removed from a group if they need to be reassigned. + +6. **Shuffle Groups** + +The shuffle feature allows users to enter a **preferred team size**. +The program distributes students across available groups while trying to keep the groups balanced. + +7. **Exit Program** + +Allows the user to safely terminate the application. + +### Program Menu + +When the program starts, the user sees a command-line menu: + + +### Challenges Encountered + +Some challenges included: + +- Designing a system to efficiently search students and groups +- Ensuring groups remained balanced during shuffling +- Managing relationships between students and groups +- Handling user input safely in the command line + +### Solutions + +To solve these challenges we: + +- Used **IDs for students and groups** to simplify searching +- Used **collections such as ArrayList** to store dynamic lists of students and groups +- Built methods that handle student movement and group assignment cleanly + +--- + +## Sprint 3 — The Reflection + +### What Works Well + +The program successfully allows users to: + +- Manage students and groups +- Automatically distribute students across groups +- Adjust group assignments manually +- View organized group information easily + +The menu system provides a simple interface for interacting with the program. + +### Improvements With More Time + +If we had more time, we would improve the program by adding: + +- Data persistence (saving students and groups to files) +- A graphical user interface (GUI) +- More advanced shuffle algorithms +- GPA-based or skill-based group balancing +- Editing or updating student information + +### Java Concepts Used + +This project heavily utilized several core Java concepts: + +- **Classes and Objects** +- **Constructors** +- **Encapsulation with getters and setters** +- **Collections (ArrayList)** +- **Loops** +- **Conditional statements** +- **User input with Scanner** +- **Method organization and modular design** + +### What We Learned + +This project helped us better understand: + +- How to design object-oriented programs +- How to manage relationships between objects +- How to structure larger Java programs +- How to document and explain software design decisions -When the application starts, the user is presented with a menu of available actions. +--- \ No newline at end of file