From 670850ad250de6aab17d17e44ac81d4ca60201bc Mon Sep 17 00:00:00 2001 From: nomadriding Date: Tue, 25 Jun 2024 13:07:53 -0400 Subject: [PATCH 01/31] recreate ironschool homework --- .idea/.gitignore | 3 +++ .idea/compiler.xml | 13 ++++++++++++ .idea/encodings.xml | 7 +++++++ .idea/homework-java-ironschool.iml | 9 +++++++++ .idea/jarRepositories.xml | 20 +++++++++++++++++++ .idea/misc.xml | 16 +++++++++++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ ironSchool/pom.xml | 17 ++++++++++++++++ .../src/main/java/org/example/Main.java | 7 +++++++ .../src/main/java/org/example/UserChoice.java | 5 +++++ 11 files changed, 111 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/homework-java-ironschool.iml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 ironSchool/pom.xml create mode 100644 ironSchool/src/main/java/org/example/Main.java create mode 100644 ironSchool/src/main/java/org/example/UserChoice.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..828a7f5 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..31817d1 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/homework-java-ironschool.iml b/.idea/homework-java-ironschool.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/homework-java-ironschool.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..c012d12 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7d98804 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ironSchool/pom.xml b/ironSchool/pom.xml new file mode 100644 index 0000000..898e2ac --- /dev/null +++ b/ironSchool/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.example + ironSchool + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/ironSchool/src/main/java/org/example/Main.java b/ironSchool/src/main/java/org/example/Main.java new file mode 100644 index 0000000..407f157 --- /dev/null +++ b/ironSchool/src/main/java/org/example/Main.java @@ -0,0 +1,7 @@ +package org.example; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java new file mode 100644 index 0000000..021c476 --- /dev/null +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -0,0 +1,5 @@ +package org.example; + +public class UserChoice { + +} \ No newline at end of file From a8ecb8a02b650d2f4055ef5b76d3149c1789557a Mon Sep 17 00:00:00 2001 From: nomadriding Date: Tue, 25 Jun 2024 13:09:01 -0400 Subject: [PATCH 02/31] add test --- ironSchool/src/test/java/Main.java | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 ironSchool/src/test/java/Main.java diff --git a/ironSchool/src/test/java/Main.java b/ironSchool/src/test/java/Main.java new file mode 100644 index 0000000..7046417 --- /dev/null +++ b/ironSchool/src/test/java/Main.java @@ -0,0 +1,2 @@ +public class Main { +} From c91b837c4ce04db53bfc8a25ab1cf653c09fddee Mon Sep 17 00:00:00 2001 From: Estefanymary Date: Tue, 25 Jun 2024 14:08:05 -0400 Subject: [PATCH 03/31] resubmiting Teacher --- ironSchool/.idea/.gitignore | 8 ++++ ironSchool/.idea/compiler.xml | 13 ++++++ ironSchool/.idea/encodings.xml | 7 +++ ironSchool/.idea/jarRepositories.xml | 20 +++++++++ ironSchool/.idea/misc.xml | 12 +++++ ironSchool/.idea/vcs.xml | 6 +++ .../src/main/java/org/example/Teacher.java | 41 ++++++++++++++++++ .../target/classes/org/example/Main.class | Bin 0 -> 540 bytes .../classes/org/example/UserChoice.class | Bin 0 -> 279 bytes 9 files changed, 107 insertions(+) create mode 100644 ironSchool/.idea/.gitignore create mode 100644 ironSchool/.idea/compiler.xml create mode 100644 ironSchool/.idea/encodings.xml create mode 100644 ironSchool/.idea/jarRepositories.xml create mode 100644 ironSchool/.idea/misc.xml create mode 100644 ironSchool/.idea/vcs.xml create mode 100644 ironSchool/src/main/java/org/example/Teacher.java create mode 100644 ironSchool/target/classes/org/example/Main.class create mode 100644 ironSchool/target/classes/org/example/UserChoice.class diff --git a/ironSchool/.idea/.gitignore b/ironSchool/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/ironSchool/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/ironSchool/.idea/compiler.xml b/ironSchool/.idea/compiler.xml new file mode 100644 index 0000000..828a7f5 --- /dev/null +++ b/ironSchool/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/encodings.xml b/ironSchool/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/ironSchool/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/jarRepositories.xml b/ironSchool/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/ironSchool/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/misc.xml b/ironSchool/.idea/misc.xml new file mode 100644 index 0000000..f0f8287 --- /dev/null +++ b/ironSchool/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/vcs.xml b/ironSchool/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/ironSchool/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ironSchool/src/main/java/org/example/Teacher.java b/ironSchool/src/main/java/org/example/Teacher.java new file mode 100644 index 0000000..1f846f1 --- /dev/null +++ b/ironSchool/src/main/java/org/example/Teacher.java @@ -0,0 +1,41 @@ +package org.example; +import java.util.UUID; + + public class Teacher { + private String teacherId; + private String name; + private double salary; + + public Teacher(String name, double salary) { + this.teacherId = generateId(); + this.name = name; + this.salary = salary; + } + + private String generateId() { + return UUID.randomUUID().toString(); + } + + public String getTeacherId() { + return teacherId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } + } + + + diff --git a/ironSchool/target/classes/org/example/Main.class b/ironSchool/target/classes/org/example/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..8a26bbede35478ee648da19fff6f147a51234845 GIT binary patch literal 540 zcmZvZ%T59@6o&tD8)h5@LGZ5N3S2l#7pNN(;{q=UhK;L&4VHAKqzqmjOBb5B@Bw@% zzasLw?5t#iK!R(Hn|>%#b^fk&KTR z(v4=Np>^i8@DB27H@xa5862TdlRGm52H-e$i zmXSE0ggs%dcu$d1YU@5%U2de!zr{>^E60iV57Z)3m;kGd>sjZM&&_~(%QI{SucIfX zFHWRA+O?zY*=wSX3O&AEDKPu|6qhLrXlJx%cVEGt5_^TBwShENDf-g_tYMup7aQ0l l#WwFJFw&mkl;&Sh_yO3jCMx}4?ia+x7Pd)es8LLz{son#aCra# literal 0 HcmV?d00001 diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class new file mode 100644 index 0000000000000000000000000000000000000000..2475b2fc85325612906c1cafa11b9b69a5d6abe5 GIT binary patch literal 279 zcmZuryKcfj5S;Y`g98{*M6`53k^6v_(_Bx&JJb_&6v#*&3ZILNGCFrX~vF;%VH(1cKT)p)m9$}z4Y<9 zS3)QX#s({K)j&A<2A$dP5Hq?p;Nyw0d7VS%7Ar!V H(L-_piP}2V literal 0 HcmV?d00001 From e7b78dee7ef0b6204a2733d9bc6cd4f4d0bebec3 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 10:02:52 -0400 Subject: [PATCH 04/31] Add jdk file, add welcome method --- .../src/main/java/org/example/UserChoice.java | 9 +++++++++ .../target/classes/org/example/Teacher.class | Bin 0 -> 1081 bytes .../target/classes/org/example/UserChoice.class | Bin 279 -> 690 bytes 3 files changed, 9 insertions(+) create mode 100644 ironSchool/target/classes/org/example/Teacher.class diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 021c476..6ddde25 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -1,5 +1,14 @@ package org.example; public class UserChoice { + public static void main(String[] args) { + welcome(); + } + public static void welcome(){ + System.out.println("Welcome to Advance Learning \n"); + System.out.println("Choose a name for this school: "); + + } + } \ No newline at end of file diff --git a/ironSchool/target/classes/org/example/Teacher.class b/ironSchool/target/classes/org/example/Teacher.class new file mode 100644 index 0000000000000000000000000000000000000000..96360a06e77d1f60d0278be4cc31a88b24746fe9 GIT binary patch literal 1081 zcmZ`&U2hUm5IvW#?XF7;6lndZQf)14wQHZzzDP`(kowS;_Y2(6ZI)fLEJlBonn*Q1 z_yhb=#+l1PYh6Qf@60e~=FGXXzkdJt3E&kDEo6{2kh76TL7;Rg-%Hn*!N`5vzf^-* zpzzWQy!c2U+idkLtiUv2*|-B+U_FdRuKFOy?|kK+DLJ@Mk$^Q)fr@0Tj)wx(W~+N$ z^fZpVVAM9L%&LtwlmyIpj^pG?dTPbSI;Z9WIaZ9V*{EZKxJ{%lqmKfjW8p6D8Mtrb z0k#BIbt?S|+p^|Hwvz$6ATQIZ=Un^IuAxR*$&64u?u$ zt?LEqWIFDv=uGx~id4GcK>9rydF&^_Tzuh81Zv$B!P)}$NX3bKEQ3Mr35`nDWMS1( zh%gV6a!(T#=!IxflQ4@&uBpjdr{Odjs5c%Hw3AK;ED^Rz&J68BmQH#PvN9~TzDZ-c z4G3C}Z8{&5rzkT=_lENg!f~!(%usapXDB<(8LD42@CluD0s$r^Ti|sm(^*FmI}~kD z5h{UQJf)j0ZYi|IO*8bP1xs2U(#`)F-?4dxho8yJfLj!FxTH&RGIO1m6xdtB-2|R@ zzM^;=T)hF#FTu@JaQQZPGZox|LmgSGBRvT5)cRaY!yg@JPxIK)73$hAEafO9atQ3> ySyIcT9G;M;sD2{jrUZ>tBF}NKB$CyN7o5Gn-e^u_hluR{hX}t0tMBTLFa7|Kk)p@| literal 0 HcmV?d00001 diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 2475b2fc85325612906c1cafa11b9b69a5d6abe5..160c2a247fb228b18f4e10c7adbcbccd08031e37 100644 GIT binary patch literal 690 zcmZuvO>fgc5Ph4tapIb$O=u_|rOS890Sk@KBT3Q`W9@qE2`J2Suk{QL#rDegsRpcx{Fv4)nw=CL|eNv_IS@@jglvs$3_ z#FVCfCeR%2Pa?F@2@%Cu_vr)cW{Li!ij!O?Z!7H%j;zVFK=@JTnJsh&7qAhc8)Fk& z|G|$xSG6vPYUgaSot`x|HhJw#S&wU{RWWL#FR=S=0VQiIpC6v8GSf2E%9W;^$tc1$ z1|crR*uiCi{t6hfIq{%*$v(qHqq7&X3o%CflQymj?2)^zv{bTGg_a+zll76QWR=mM zKb8W)fj#8gx~VDk%Xu-??v0w}^z>4jseGcG@%GXg_-cWjboGoz#4D5`r@`?3DpHIq zHzPuSMOYvj+quj13*!lN&u9O@PXIT#rv^6+G$H(IDX-B=s0H=f{qGQ8_|w2Hr4Rem z>y+^#0eg_NI)u7Ok1u}2&*ud{5T4ii3nCz^TmRGtxP{yFcl@C&>mM#DZGA=D>wUvT budh&hFfN*MgD@a>UKuZDo!&dN8@T%y&?S&T delta 136 zcmdnQI-QB@)W2Q(7#J9A83ZPB>C3P)a4<56 Date: Wed, 26 Jun 2024 10:04:28 -0400 Subject: [PATCH 05/31] import scanner --- ironSchool/src/main/java/org/example/UserChoice.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 6ddde25..3d6b576 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -1,12 +1,19 @@ package org.example; +import java.util.Scanner; + public class UserChoice { + private static Scanner scanner; public static void main(String[] args) { welcome(); } public static void welcome(){ System.out.println("Welcome to Advance Learning \n"); System.out.println("Choose a name for this school: "); + schoolName(); + } + + public static void schoolName(){ } From 532232d39ea9c994f60e2ba22ea267b43926897a Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 10:05:59 -0400 Subject: [PATCH 06/31] save school name --- ironSchool/src/main/java/org/example/UserChoice.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 3d6b576..97e6b0d 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -14,7 +14,7 @@ public static void welcome(){ } public static void schoolName(){ - + String school = scanner.nextLine(); } From da95d3e78031b3bc29c960ce1a12e3bfa6cf4785 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 10:20:47 -0400 Subject: [PATCH 07/31] create profanity checker --- .../src/main/java/org/example/UserChoice.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 97e6b0d..0b6e3e7 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -1,5 +1,9 @@ package org.example; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Iterator; import java.util.Scanner; public class UserChoice { @@ -18,4 +22,21 @@ public static void schoolName(){ } -} \ No newline at end of file + + public static Boolean containsProfanity(String input){ + List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt", "whore"); + Iterator var2 = profanities.iterator(); + + String profanity; + do { + if (!var2.hasNext()) { + return false; + } + + profanity = (String)var2.next(); + } while(!input.toLowerCase().contains(profanity)); + + return true; + } + +} From aaa96ad7bb6af144ef433fca6c394d24e37d8244 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 10:25:49 -0400 Subject: [PATCH 08/31] add number checker --- ironSchool/src/main/java/org/example/UserChoice.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 0b6e3e7..894196e 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -5,6 +5,8 @@ import java.util.List; import java.util.Iterator; import java.util.Scanner; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class UserChoice { private static Scanner scanner; @@ -39,4 +41,9 @@ public static Boolean containsProfanity(String input){ return true; } + public static Boolean containsNumbers(String input){ + Pattern pattern = Pattern.compile("\\d"); + Matcher matcher = pattern.matcher(input); + return matcher.find(); + } } From d3430087cfb30802dae3b88844358ba975708f58 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 10:28:15 -0400 Subject: [PATCH 09/31] implement checkers on schoolName --- ironSchool/src/main/java/org/example/UserChoice.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 894196e..9ebc390 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -20,7 +20,14 @@ public static void welcome(){ } public static void schoolName(){ - String school = scanner.nextLine(); + while(true) { + String school = scanner.nextLine(); + if(!containsProfanity(school) && !containsNumbers(school)) { + return; + } + System.out.println("Not allowed to use numbers or profanity"); + schoolName(); + } } From 8f1e0be02f1de5e7b0a30324a8256e8be568e905 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 11:53:02 -0400 Subject: [PATCH 10/31] create teacher quantity and teacher name --- .../src/main/java/org/example/UserChoice.java | 52 ++++++++++++++++-- .../classes/org/example/UserChoice.class | Bin 690 -> 4112 bytes 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 9ebc390..4b5272b 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -1,15 +1,11 @@ package org.example; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Iterator; -import java.util.Scanner; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; public class UserChoice { - private static Scanner scanner; + private static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { welcome(); } @@ -23,6 +19,7 @@ public static void schoolName(){ while(true) { String school = scanner.nextLine(); if(!containsProfanity(school) && !containsNumbers(school)) { + teacherQuantity(); return; } System.out.println("Not allowed to use numbers or profanity"); @@ -30,6 +27,49 @@ public static void schoolName(){ } } + public static void teacherQuantity(){ + System.out.println("How many teachers should work in this school?"); + int teacherQuantity; + while(true){ + try{ + teacherQuantity = scanner.nextInt(); + scanner.nextLine(); + if(teacherQuantity > 0){ + break; + } + System.out.println("Enter a number above ZERO"); + } catch (InputMismatchException e){ + System.out.println("Uh oh! please enter a number. "); + scanner.next(); + } + } + collectTeacherNames(teacherQuantity); + } + + private static String getFilteredName(String type, int i) { + while (true) { + System.out.println("What should this " + type + " be called?"); + String name = scanner.nextLine(); + if (!containsProfanity(name) && !containsNumbers(name)) { + return name; + } + System.out.println("Uh oh, that is not allowed. Try again"); + } + } + + private static void collectTeacherNames(int teacherQuantity) { + String[] teacherNames = new String[teacherQuantity]; + + for (int i = 0; i < teacherQuantity; ++i) { + teacherNames[i] = getFilteredName("teacher", i); + } + + System.out.println("Teacher names:"); + for (String name : teacherNames) { + System.out.println(name); + } + } + public static Boolean containsProfanity(String input){ diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 160c2a247fb228b18f4e10c7adbcbccd08031e37..27d77d6d50963a82465c823d7ab81e39fae8d3fa 100644 GIT binary patch literal 4112 zcmai1S#;Fa8UAFCEqM?gGR6=a2m%av12;ejWxy;B6gOjIGRCeAX)DhNkFZ9XXf!tN zzR;#?x~5HNo3=Eq(;Y}_3~6Y(w@J5$zT~av^r=sM?dc(Lzbk2MIreFf&q!DI{`ddC z@89nA%dg+Q1K=?J97h$ZWyDm}pjN_~i~6MAW$E^K*Xgl~M%I&1d&sm+uUkTOYuiv9 z3hHFURjd-?>l}By%ebT$ik8uJwq&?HdB@Be667hv$~pz34y#cwBcWmq?pdNfGhOnG z0<}728fi@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-8%mbC zh;h7{MCy4DPN0F$I&qT>wMOf9rerj6Kub=b&@a0{Av$827}EAWUrp7tsKh5Mpj-^0w>%V_Q+fd>fcK|(*U0Jniue?YGbr|!cKegBKmk4Qm^ zM50whA}+3xA;edhE+VKWn_tA4boJql%~z4^*qF?0oWt478W& z-XCj>ZMur}osF?Q2Wz<2RKvB)F-rbZq+tMh2jdN1p=;1h;791KZl=s}Mxuw%AL2|8 zPVhb={M}9rGSfUWUQ>hWCLVwrb7=Fxx2&k+_>@~3jxA2&RD^RNE zFnNt%?~?Em&h)p>;=Q|O@qwr3|IW&tyhfcdzZ&i%XfUW-kY+LsFdk>HAA?NAvz#4X zphgV1?nh(`8^{ejPlO`>liEc02&CphvMQ=x1H)#?a95Kd|04<+ zj)vK_HhFmtA5C`<=%@NRXYtt(Wzd`I{R}+EAfKo9M;9_i)Nz2SmYw1jZd0pD*FS+5 zs8_+y7K(L;uK}ok0WBjp@Z?QA{X8}=cATL5DU^DV461MkKj&MazL)s>Eq>20(MJD( JSMVn^{TCi60o(up delta 239 zcmYLDNe;q5408(8c7_T;#R<`&>{2fX?!1Br@dS|ilJ)?I0}tR)2&Zg^v6G4Iv&hgLe*JqDVTL)`qVwCn`P|g6k)-Jv1LYxE)1 Date: Wed, 26 Jun 2024 12:07:04 -0400 Subject: [PATCH 11/31] add course Names --- .../src/main/java/org/example/UserChoice.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 4b5272b..de14057 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -44,6 +44,7 @@ public static void teacherQuantity(){ } } collectTeacherNames(teacherQuantity); + courseQuantity(); } private static String getFilteredName(String type, int i) { @@ -70,6 +71,38 @@ private static void collectTeacherNames(int teacherQuantity) { } } + private static void courseQuantity() { + System.out.println("How many courses should this school have?"); + int courseQuantity; + + while (true) { + try { + courseQuantity = scanner.nextInt(); + scanner.nextLine(); + if (courseQuantity > 0) { + break; + } + System.out.println("Enter a number above ZERO"); + } catch (InputMismatchException e) { + System.out.println("Uh oh, please enter a number. Try again"); + scanner.next(); // Clear invalid input + } + } + collectCourseNames(courseQuantity); + } + + private static void collectCourseNames(int courseQuantity) { + String[] courseNames = new String[courseQuantity]; + + for (int i = 0; i < courseQuantity; ++i) { + courseNames[i] = getFilteredName("course", i); + } + + System.out.println("Course names:"); + for (String name : courseNames) { + System.out.println(name); + } + } public static Boolean containsProfanity(String input){ From ca4136ce560a81cc6b21fe46cc6b4826b1f72385 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 12:10:53 -0400 Subject: [PATCH 12/31] clean profanity checker for excess code --- .../src/main/java/org/example/UserChoice.java | 20 +++++++----------- .../classes/org/example/UserChoice.class | Bin 4112 -> 4725 bytes 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index de14057..37c622a 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -105,20 +105,16 @@ private static void collectCourseNames(int courseQuantity) { } - public static Boolean containsProfanity(String input){ - List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt", "whore"); - Iterator var2 = profanities.iterator(); - - String profanity; - do { - if (!var2.hasNext()) { - return false; - } - profanity = (String)var2.next(); - } while(!input.toLowerCase().contains(profanity)); - return true; + public static Boolean containsProfanity(String input){ + List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); + for (String profanity : profanities) { + if (input.toLowerCase().contains(profanity)) { + return true; + } + } + return false; } public static Boolean containsNumbers(String input){ diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 27d77d6d50963a82465c823d7ab81e39fae8d3fa..2be94d83a67e79e637b6e1b8bf0202af441f0f43 100644 GIT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yXiZS^`6yYQ5br!72#X9cq44p)}^ z)j7-9h375o#tYJ`&vUs@Ox}buNs+%NAb2tAq=M1u|2VLXqGSkbopCakvJ$vT6u8=*2QfK%-f5+K8#=F zO`xO?lMcYm(bVL~-qQ=qGrbQP3FLGST%)&^q?=7dAcKT6F&4KV2cxO>7)(U=5Ct9i zcpLA~ubaP%r(MTboh9Ky{Me8l*SN0e*Qk>!c~X+i%&HWrrtCv-cB4QUt7+^W_{FEj z^Zs+3-_$+uLv{jp_7KJ3>BXqQI20xO6xZo27a*6`Tak|OWLp@gV-ejZvMr@+F-rJN zh8LBbS78$7@CvA0fogJ^!$7NBgxW1 zOWmMU4$Q?zEXowiEZA>A*KtDpgHbn;u14Z-YVBeU$`DWK_9Id4#Aq-`x>@tA@;BQ( zYy8a)&wc)8rzhZV);%r$1cJWO)7T`ixa>5x3LJo;CD3_-vj+suqj8D14-Zf3!=w8L ze&+S*JV8u*vX*nn8d!t^_*e)H)VdMVu`JF)TF&LBq2NdYJxRF>c#V5;l7Xn&`52!t z;2MlXAFUcr5l-FVlviRfTnn}vU{2a}L`N{jX^b%y;>y9&$nfk;;7MO8nLf9;EZ&Db zgFI7DggaS3tC+&ogkLjM59%JKXgT4=X`CUfMfG>%EP)MtI&{}2BoP4jSrj(+V&5t3 pKZ!i`kceTAkU_70@Uqx&4xiCz(0rc%SGdHPdd@E6D!#>-e*p|LVe$X~ From d29626289afea68e64bb87ddf255d36bba46b7b3 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 12:12:44 -0400 Subject: [PATCH 13/31] add command menu with switch case statement --- .../src/main/java/org/example/UserChoice.java | 59 ++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 37c622a..7d281bf 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -104,8 +104,65 @@ private static void collectCourseNames(int courseQuantity) { } } + public static void commandMenu() { + while (true) { + System.out.println("Please select from the following options:"); + System.out.println("1. ENROLL"); + System.out.println("2. ASSIGN"); + System.out.println("3. SHOW COURSES"); + System.out.println("4. LOOKUP COURSE"); + System.out.println("5. SHOW STUDENTS"); + System.out.println("6. LOOKUP STUDENT"); + System.out.println("7. SHOW TEACHERS"); + System.out.println("8. LOOKUP TEACHER"); + System.out.println("9. SHOW PROFIT"); + System.out.println("0. EXIT"); + System.out.println("SELECT THE NUMBER:"); - + try { + int choice = scanner.nextInt(); + scanner.nextLine(); // Clear the buffer + + switch (choice) { + case 1: + // Enroll logic here + break; + case 2: + // Assign logic here + break; + case 3: + // Show courses logic here + break; + case 4: + // Lookup course logic here + break; + case 5: + // Show students logic here + break; + case 6: + // Lookup student logic here + break; + case 7: + // Show teachers logic here + break; + case 8: + // Lookup teacher logic here + break; + case 9: + // Show profit logic here + break; + case 0: + System.out.println("Exiting..."); + return; + default: + System.out.println("Invalid choice, please try again."); + } + } catch (InputMismatchException e) { + System.out.println("Uh oh, please enter a valid number."); + scanner.next(); // Clear invalid input + } + } + } public static Boolean containsProfanity(String input){ List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); From 9aeb28015a07e2fc7d5d39a49d1070197edb70cd Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 12:15:37 -0400 Subject: [PATCH 14/31] create course class, with getters and setters --- .../src/main/java/org/example/Course.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 ironSchool/src/main/java/org/example/Course.java diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java new file mode 100644 index 0000000..f390fce --- /dev/null +++ b/ironSchool/src/main/java/org/example/Course.java @@ -0,0 +1,37 @@ +package org.example; + +public class Course { + private String courseId; + private String name; + private double price; + private double money_earned; + + public Course(String name, double price) { + this.name = name; + this.price = price; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public double getMoney_earned() { + return money_earned; + } + + public void setMoney_earned(double money_earned) { + this.money_earned = money_earned; + } +} From 346532ecb4bf2bdc5672b14d3104773ef905141c Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 12:24:06 -0400 Subject: [PATCH 15/31] refactor and add Teacher --- .../src/main/java/org/example/Course.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index f390fce..3d323fe 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -5,10 +5,12 @@ public class Course { private String name; private double price; private double money_earned; + private Teacher teacher; public Course(String name, double price) { this.name = name; this.price = price; + this.money_earned = 0.0; } public String getName() { @@ -27,11 +29,22 @@ public void setPrice(double price) { this.price = price; } + public Teacher getTeacher(){ + return teacher; + } + + public void setTeacher(Teacher teacher){ + this.teacher = teacher; + } + public double getMoney_earned() { return money_earned; } - public void setMoney_earned(double money_earned) { - this.money_earned = money_earned; + + public void addEarnings(double earnings){ + if (earnings > 0){ + this.money_earned += earnings; + } } } From ad440fc437cc32d015055980c61b098a9f68621c Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 12:34:37 -0400 Subject: [PATCH 16/31] add courseId autogenerate --- ironSchool/src/main/java/org/example/Course.java | 6 ++++++ ironSchool/src/main/java/org/example/UserChoice.java | 2 ++ 2 files changed, 8 insertions(+) diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index 3d323fe..c7f8e59 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -1,6 +1,7 @@ package org.example; public class Course { + private static int courseCounter = 0; private String courseId; private String name; private double price; @@ -8,11 +9,16 @@ public class Course { private Teacher teacher; public Course(String name, double price) { + this.courseId = generateCourseId(); this.name = name; this.price = price; this.money_earned = 0.0; } + private static synchronized String generateCourseId() { + return "COURSE-" + (++courseCounter); + } + public String getName() { return name; } diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 7d281bf..45ace47 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -164,6 +164,8 @@ public static void commandMenu() { } } + + public static Boolean containsProfanity(String input){ List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); for (String profanity : profanities) { From 40a174a1963ed8798bc0cd01edb6a04f6f7ca57d Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 13:14:55 -0400 Subject: [PATCH 17/31] create course cost --- .../src/main/java/org/example/Course.java | 2 +- .../src/main/java/org/example/UserChoice.java | 25 +++++++++++------- .../target/classes/org/example/Course.class | Bin 0 -> 1978 bytes .../classes/org/example/UserChoice.class | Bin 4725 -> 6154 bytes 4 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 ironSchool/target/classes/org/example/Course.class diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index c7f8e59..4060be1 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -11,7 +11,7 @@ public class Course { public Course(String name, double price) { this.courseId = generateCourseId(); this.name = name; - this.price = price; + this.price = 1000; this.money_earned = 0.0; } diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 45ace47..cbbd72c 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -6,6 +6,9 @@ public class UserChoice { private static Scanner scanner = new Scanner(System.in); + public static double totalCourseCost = 0.0; + private static List courses = new ArrayList<>(); + public static void main(String[] args) { welcome(); } @@ -61,7 +64,7 @@ private static String getFilteredName(String type, int i) { private static void collectTeacherNames(int teacherQuantity) { String[] teacherNames = new String[teacherQuantity]; - for (int i = 0; i < teacherQuantity; ++i) { + for (int i = 0; i < teacherQuantity; i++) { teacherNames[i] = getFilteredName("teacher", i); } @@ -91,17 +94,19 @@ private static void courseQuantity() { collectCourseNames(courseQuantity); } - private static void collectCourseNames(int courseQuantity) { - String[] courseNames = new String[courseQuantity]; - for (int i = 0; i < courseQuantity; ++i) { - courseNames[i] = getFilteredName("course", i); + private static void collectCourseNames(int courseQuantity) { + for (int i = 0; i < courseQuantity; i++){ + String name = getFilteredName("Course", i); + Course course = new Course(name, 1000); + courses.add(course); + totalCourseCost += course.getPrice(); } - - System.out.println("Course names:"); - for (String name : courseNames) { - System.out.println(name); + System.out.println("Course names and prices: "); + for(Course course : courses) { + System.out.println(course.getName() + " : $" + course.getPrice()); } + System.out.println("Total course cost: $" + totalCourseCost); } public static void commandMenu() { @@ -164,7 +169,7 @@ public static void commandMenu() { } } - + public static Boolean containsProfanity(String input){ List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); diff --git a/ironSchool/target/classes/org/example/Course.class b/ironSchool/target/classes/org/example/Course.class new file mode 100644 index 0000000000000000000000000000000000000000..c97f853282dcf35baceb4002c3fa3814a05f7034 GIT binary patch literal 1978 zcmaJ>+fo}x5IrLaNfwKQWG*%a+le6(!nSg;<0Qg_SU{{qfGZ-TTzN=_)s$Ex?W$Ib zD||&Blc)SbZl;p*gFhf2mCBjjwO9)gRcU9ox2OA@)7|sWzb{__c!(z%#1Ky*VPFhN zfyrm`xvX@g-LC8&JX5A8kX*HF%UctOmzMW4NaIop83W@m1PYGZuBabmx7SgXnse;- z6=SrOtz7A;z))`qOqG@!XOWwpYuWAUCC17c$YD|-ZTg3`Z(+1&!N6thnXqM7CD(sk zCw@T3m^E+(R|Up;u4OX6*wEH%2IjTZ=sLDK`A$jKRxSPEx`7+GDKHVFBuLv+E|1j< z4EVNzTUZpB?aCt(uubWGV|j<%^*w2OeSzsx{Q@%Y7$~A7kn)r?4|UAxMpU4^z+4rW zDV-;|vAj=qHK#=ixrSw{o#XC-a`)sxhn7OaF=c08x|V(qjS272BBH4`vIMF#Nvf^9 z9g4+W|MhNqL}HycP2VShd@S<@4LlMW5+xs6hAtrk%EN+=rk3Hsf!meRNH3i+$8g(` z(g=*pR%?@GVsDUCT30OCPBcAf9&O8BNISi1cEX;_G}$+%+Oo7p;{o-%y3^Q(j~vJA zd#>zlEAP;0^>azoGT6Xo3R}9$p9?IWHKk=gcaBsg=*^(;ThjC#_e9|5sA{2O5cILM zTOHM3Y&g!*aj$y5su9Z@2lq~TYJ~f@5&vKStI=i)L)2ua)3iKQO`}ewYP(;5)!e)z z*z9$iqgU(5eqZ%dXb3EwV>k+U3OfSV|KF82LBJAkaf)J`l_WBHl(>uODfU;+sK0U| z{gpH5uN(}n181CRMSH067Q75 zNn-eo?gBbp(m#5c&&uFXg>O3GSosC=+BFt&o%K=Z_;d(S2)v8;Xwh`n=M~W&*DPk7US0;C*}$#;VZgHISKKhk)D|3FIE`4}ipdsgmU)RUQU%i$E4H z0HS5o3VetMVXUYkOT&s3M*{f>9}j>;6j>SuvO*xYF94$3Ndx(0q#|>}id04dsSXs` zXDZ!1`C|5`U)Y3CUtq3ihTRwUYn=5R?y)WIv#TCNaODS;%45|R=pjSJAtpH|YknW; s@-Gms{*A@iYnp4c%@Xwgl(rbw@fp`NzdqvsF}~nihPyAZja^**4+ybv82|tP literal 0 HcmV?d00001 diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 2be94d83a67e79e637b6e1b8bf0202af441f0f43..49b3775ea4ba44687bb50fbc9e0a51314564464c 100644 GIT binary patch delta 3253 zcmZuz3wTrI8GirV&PjS`OIliJp&V$bEtD1zuu^c8Hb6(4_94YuWNaY~B_&NTNx6s; zQRgOeV>7zRoX&e3n-f|s<)XOh2D**0$!=bD)3M1mcaieG@N}svp`OkmOcfS97 zzwiAn$$MqHX1QLuc<6Z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2024 13:30:09 -0400 Subject: [PATCH 18/31] create course and teacher method for menu --- .../src/main/java/org/example/UserChoice.java | 24 +++++++++++++----- .../classes/org/example/UserChoice.class | Bin 6154 -> 6559 bytes 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index cbbd72c..052e3c7 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -8,6 +8,7 @@ public class UserChoice { private static Scanner scanner = new Scanner(System.in); public static double totalCourseCost = 0.0; private static List courses = new ArrayList<>(); + private static List teacherNames = new ArrayList<>(); public static void main(String[] args) { welcome(); @@ -26,7 +27,6 @@ public static void schoolName(){ return; } System.out.println("Not allowed to use numbers or profanity"); - schoolName(); } } @@ -62,10 +62,8 @@ private static String getFilteredName(String type, int i) { } private static void collectTeacherNames(int teacherQuantity) { - String[] teacherNames = new String[teacherQuantity]; - for (int i = 0; i < teacherQuantity; i++) { - teacherNames[i] = getFilteredName("teacher", i); + teacherNames.add(getFilteredName("teacher", i)); } System.out.println("Teacher names:"); @@ -107,6 +105,7 @@ private static void collectCourseNames(int courseQuantity) { System.out.println(course.getName() + " : $" + course.getPrice()); } System.out.println("Total course cost: $" + totalCourseCost); + commandMenu(); } public static void commandMenu() { @@ -136,7 +135,7 @@ public static void commandMenu() { // Assign logic here break; case 3: - // Show courses logic here + showCourses(); break; case 4: // Lookup course logic here @@ -148,7 +147,7 @@ public static void commandMenu() { // Lookup student logic here break; case 7: - // Show teachers logic here + showTeacherNames(); break; case 8: // Lookup teacher logic here @@ -169,6 +168,19 @@ public static void commandMenu() { } } + public static void showCourses(){ + System.out.println("Courses: "); + for(Course course : courses){ + System.out.println(course.getName()); + } + } + + public static void showTeacherNames(){ + System.out.println("Teachers: "); + for(String teacher : teacherNames){ + System.out.println(teacher); + } + } public static Boolean containsProfanity(String input){ diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 49b3775ea4ba44687bb50fbc9e0a51314564464c..390cb51ffb2c67c83519872f9f068c2a71e5421f 100644 GIT binary patch delta 3372 zcmY*b33yc189jG0Gw;pI%QgvQgD`{uA%O{mrASQNtUKD) zUKVKUidLvtA)weo8V`O^$8EUXsCHhTl8lvTQLsu!7^{tkTxA6+)(E6FS}J`JsdJW; zTC3v@v>T=Fah?b|6s*^Ar?K2UrZ9po9o2{mWED@a?rsl7TFdHJt_`)nMmdLx zO~%7czu02D;`BT3(y`6B?981W6L42{ba!@z6>Jyqc67Fug*S!Pt#1#PS?liEyJypG zKtm7i)#1XIjT+a;y!&)~MH;WPn8&*$A@}R}DjqOibLFT#*sbGhc+mLNm04j3Mj&h}c~ z);IYo>z6bHtAZ+iNS96X`vUd#HA@!T%PO8WwkyM8`vfv(B=&-hOXgM8HLBRpBVVxf zG*->2Tv*jWMF%N7Ga+oRtLURUud{_0H`LFsrh;c_>tw=QCMSnUe6T7|RoUokTv+9+ zTT(l>s$rJ2blwpiM@>_^)^u#NDD09O$90^L>*;dcjukWfR6Hl3Rc&gEwnbX~e!q(6 zjUsiN_=!=Y7B4+bI&3Yod@9aR)ILl{sQ8(Hb9Hyi9V%WCaII{MwyaTcmQX`oyr(^^ z;un-?>5fD-yoT2m{8GoS@N45Kb-u3~ztQnq>BQt{N1$V4xU(|U71q#=3p##>-y7+k zN$x-BcnfbEm7cMg?+7?ntkUov{-of29e>6L##YZ#^*#JW$A|dHIPaO8`Z4~d;1eC6 zqFf-`5L&h|TT6ETL&rbyFXLuywEI6YBL8b_(njVD2xMN#yg8knq0KV=G<;_4*RC^G z>*I|Nv;oa+1uV10IHzS9K7GFNfZmhp)5K^|sE9F)HBn^br@Sb}8E>Z)&Z0$b;hW_v z5~?T>7}nSk4Ym6$CG5JQa*IWvIufDH?W8K)rHDxaV~w7aY$KMc7`LQ)oMi$9_CjvV z$!r>pLS~gmW{jC#%qB+tC5|1q%zc)Y#Qbxlaq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nprr^Fb;=Nez0!#WY3xt>Cy ziadc)jgr=$L{)gU1lzj8@=QQq8i_CxZ44mI36F8eHQ6>^Am2Fb$~Qi6xnovn7>DsJ zaHlL0&YG+-Quc3LTkv;`;MxucpC59kl(XP$pL`6W+Z4ITr#uD}{DV(DA%K74BfdHD zFZ`Q3@^Tr6l(Y3gN!%@#mo?e}?O5TuL4ge);}Z9sNJ&^XdQ%I%kQdyr@tMZL9?7R0 z>HIp8KMZmw6-ql(3^i?Hpbxq6!Pog}H81BACXmJFXyjlFuVrH_axoEkn9R2!7ZeoW zKe$ZUD;!R$yo!8*Z<`ufeIo`>|HSq zr{^l{j4~od`^f5;i7A^3f!PdQIbE4UEOU8%9;RXbu;O%LyGA@RRx@zjL?%~*G$wAq zSR^rOs6nl?LE%>zEvbG{_6umLvChxUeiZKFTz4S154Xkqdn_V8c(Dh%du=Z=ifcXQfB?n!arA$7cmyj@Hh$Z&iTxmAx;}%BxY#8U?8`=`um~$TV8Qex`vOQe_bjNVzeDk$ zF;?nTSeU}Ht4LF@cYrZ=3du*4o8lCe$Vxpg-Tk`huI~Ouaz4b_xRP;8jMVA)W%T~$D}wW#8D83Cyu;0vg62#OS0(h z9$M;_i)Xor4^CYs*S#hT+Kx#oAR}3_A$+E^_T|YTCuX?`DAS#kX-E;FYhGf_RP|7Y1Oo*S;R zSx6HOwl}K;A{1PXagmEMp~~MSA#*N&V$2<(aV7h6Dy-K~pkND0HhzGCaFP^5Zmr_G z)Ry7?WglLvDJIM}YFRb!B(brH^VDU^^pl&%Y2d^#9>kC#VNk>Ymq-!Py3TaJB}P!O zDqKT!X2+Ihi1q{u13mcTF`Pe&u`U+%30w#q!(WeLv#dvPgF%%|$;lrw4OWrLGmA(Q gBROaAoqrw0XptkQZ1W{o Date: Wed, 26 Jun 2024 13:58:54 -0400 Subject: [PATCH 19/31] total teacher salary and profit --- .../src/main/java/org/example/Course.java | 2 +- .../src/main/java/org/example/UserChoice.java | 21 +++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index 4060be1..c216bd0 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -11,7 +11,7 @@ public class Course { public Course(String name, double price) { this.courseId = generateCourseId(); this.name = name; - this.price = 1000; + this.price = 1500; this.money_earned = 0.0; } diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 052e3c7..0e78187 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -7,8 +7,10 @@ public class UserChoice { private static Scanner scanner = new Scanner(System.in); public static double totalCourseCost = 0.0; + public static double totalTeacherSalary = 0.0; + public static double totalProfit = 0.0; private static List courses = new ArrayList<>(); - private static List teacherNames = new ArrayList<>(); + private static List teachers = new ArrayList<>(); public static void main(String[] args) { welcome(); @@ -63,12 +65,14 @@ private static String getFilteredName(String type, int i) { private static void collectTeacherNames(int teacherQuantity) { for (int i = 0; i < teacherQuantity; i++) { - teacherNames.add(getFilteredName("teacher", i)); + String name = getFilteredName("teacher", i); + Teacher teacher = new Teacher(name, 700); + totalTeacherSalary += teacher.getSalary(); } System.out.println("Teacher names:"); - for (String name : teacherNames) { - System.out.println(name); + for (Teacher teacher : teachers) { + System.out.println(teacher.getName()); } } @@ -177,11 +181,16 @@ public static void showCourses(){ public static void showTeacherNames(){ System.out.println("Teachers: "); - for(String teacher : teacherNames){ - System.out.println(teacher); + for(Teacher teacher : teachers){ + System.out.println(teacher.getName()); } } + public static void showProfit(){ + totalProfit = totalCourseCost - totalTeacherSalary; + System.out.println(); + } + public static Boolean containsProfanity(String input){ List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); From 09c41e7a4e16e928cd304163c59c0e014efcfc58 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Wed, 26 Jun 2024 14:04:21 -0400 Subject: [PATCH 20/31] add profit logic --- ironSchool/src/main/java/org/example/UserChoice.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 0e78187..753e2c1 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -9,6 +9,7 @@ public class UserChoice { public static double totalCourseCost = 0.0; public static double totalTeacherSalary = 0.0; public static double totalProfit = 0.0; + public static double totalStudentEnrollment = 0.0; private static List courses = new ArrayList<>(); private static List teachers = new ArrayList<>(); @@ -157,7 +158,7 @@ public static void commandMenu() { // Lookup teacher logic here break; case 9: - // Show profit logic here + showProfit(); break; case 0: System.out.println("Exiting..."); @@ -187,8 +188,8 @@ public static void showTeacherNames(){ } public static void showProfit(){ - totalProfit = totalCourseCost - totalTeacherSalary; - System.out.println(); + totalProfit = totalStudentEnrollment - (totalCourseCost - totalTeacherSalary); + System.out.println(totalProfit); } From fb10919daa390db2f6fb706a0efc03fcd7189ce9 Mon Sep 17 00:00:00 2001 From: "axartmiami@gmail.com" Date: Wed, 26 Jun 2024 15:35:01 -0400 Subject: [PATCH 21/31] student class --- ironSchool/.DS_Store | Bin 0 -> 6148 bytes ironSchool/.idea/.gitignore | 8 +++ ironSchool/.idea/compiler.xml | 13 ++++ ironSchool/.idea/encodings.xml | 7 ++ ironSchool/.idea/jarRepositories.xml | 20 ++++++ ironSchool/.idea/misc.xml | 12 ++++ ironSchool/.idea/vcs.xml | 6 ++ ironSchool/src/.DS_Store | Bin 0 -> 6148 bytes ironSchool/src/main/.DS_Store | Bin 0 -> 6148 bytes ironSchool/src/main/java/.DS_Store | Bin 0 -> 6148 bytes ironSchool/src/main/java/org/.DS_Store | Bin 0 -> 6148 bytes .../src/main/java/org/example/Student.java | 67 ++++++++++++++++++ 12 files changed, 133 insertions(+) create mode 100644 ironSchool/.DS_Store create mode 100644 ironSchool/.idea/.gitignore create mode 100644 ironSchool/.idea/compiler.xml create mode 100644 ironSchool/.idea/encodings.xml create mode 100644 ironSchool/.idea/jarRepositories.xml create mode 100644 ironSchool/.idea/misc.xml create mode 100644 ironSchool/.idea/vcs.xml create mode 100644 ironSchool/src/.DS_Store create mode 100644 ironSchool/src/main/.DS_Store create mode 100644 ironSchool/src/main/java/.DS_Store create mode 100644 ironSchool/src/main/java/org/.DS_Store create mode 100644 ironSchool/src/main/java/org/example/Student.java diff --git a/ironSchool/.DS_Store b/ironSchool/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..9a874b5768f336915163bb88cd434575b859f936 GIT binary patch literal 6148 zcmeH~Jr2S!425ml0g0s}V-^m;4I%_5-~tF3k&vj^b9A16778<}(6eNJu~Vz<8=6`~ zboab&MFtUB!i}=AFfm2m$tVxGT*u4pe81nUlA49C} z?O@64YO)2RT{MRe%{!}2F))pG(Sih~)xkgosK7*lF7m<7{{#Hn{6A@7N(HFEpDCdI z{ + + + + + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/encodings.xml b/ironSchool/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/ironSchool/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/jarRepositories.xml b/ironSchool/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/ironSchool/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/misc.xml b/ironSchool/.idea/misc.xml new file mode 100644 index 0000000..ea0b3a9 --- /dev/null +++ b/ironSchool/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/ironSchool/.idea/vcs.xml b/ironSchool/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/ironSchool/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ironSchool/src/.DS_Store b/ironSchool/src/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..7b0d36729e2ee777a660f9e8c6709dd97bc2fb68 GIT binary patch literal 6148 zcmeH~F>V4u3`M`g7D#EfOgRk)$PGpaPQV2S&>%r5BKkQx-ySzvsH0W%E!l7ES!;KH zv9ktX>-*^w7y&HlPOLmk%$N_j;tOYdpMH*)!|itQBJHgMp3+B5_H$d10#ZNMM4T9irw zDe%t}uwk>?toc%Twm!X{*Y{cVb)%DUIm54?049DEf6&9YUwlES5Z-O0-BN@e6nb3nTClA}DPBUXFJMFuDm5`hqcK~W{v1jnXMG``#OHBl zcUzPycoMNQF!N1jXExa{VK>7Vp*8#NklyijyDHcO%;D&pF|S5to!jK-N43@`EO zOsOPX_(6Cc_ouz;_OVJwL7eu7x*(4FkaBeqr;(a^YMe%yuJz4;D2sBhTAR&U?M_`b zn}_qdoON1_x@_+s%;#mXv%7b6+Ivi%QuS;||qRg)-U8I@$>jz zl7hn>Jc+pXAo;z#KWXxVCV7l8?#{y=V>V;Vf`-UZStDp(>)JBGH9(GYWV0Za0gT>* zneqK~z_r(yWGR~l#n<)6QI>bRAAGA;-`;6h4Xb6{d5^O2azCGEuAkoE=u*l!sB}NL ziYCR_-aC^??nlWaRS8izfsotlC<$fZ%6SrID%aBvt7$dIc6+ht4~8Al>zyn+VlnJ@ zJ7REjyj(V|{e#2Pi}6$ZoXA&ACkM8b>>8}#4HUDRFnfptSRIBM(~FlTu}r35sV1lr z35fw>fEXYKHi!Xp30SQS+B0pH7$63I#sHoV0ve)Yu+*rI4(L<~09XgJ640@hz#L)F zF<5E@4+z((fI5|%5`*h>unQCC7%VmFbjD5b!OfSe;)ScP!~8;pGwx`lo){noRvEzB z7sST<{~UgqwMD)Pp^g|J2L3Apygu?qF6_?St>5;EcddYS4-Ez5N>o5VUwH(;0MC)O ea%#Uo9pW5=rAC|u?J6CR9s-IG>WG0~VBixe;!Y(1 literal 0 HcmV?d00001 diff --git a/ironSchool/src/main/java/org/.DS_Store b/ironSchool/src/main/java/org/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3a6a05c1c81b488b69651d040e47e0b423caf343 GIT binary patch literal 6148 zcmeHK%}T>S5T0$TO({YT3Oz1(E!ftg6fdFH7cim+m736?!8BX?V}(-4SzpK}@p+ut z-GJ2`Jc-yD*!^bbXE*af_6Gn&Z$4}R)BwQ2Mkq+h5i;kx3O1Nf=sCs^Ll`Wk;~>tN z=r5Y++shEbGx#uqPv5Ts^t=V*IGWCy&392KmbSLbPT8qCx88$Vcr$-CpZ5I8HH|Km zii1q|gUcvf3~IZlDw+9F5>9kNGz>B1<|;~tYSB~kWH{Bio^d!8r!uJ3m&SmSA)iMLjzz-Op{Xt?QbS!&&(?3{(OE08-C-l4xRewW)YmQnIG}x`uARm& bNyj+XVrr0PA-hgT Date: Wed, 26 Jun 2024 18:50:24 -0400 Subject: [PATCH 22/31] add course --- .../src/main/java/org/example/Course.java | 2 +- .../src/main/java/org/example/Main.java | 2 +- .../src/main/java/org/example/UserChoice.java | 3 +++ .../target/classes/org/example/Course.class | Bin 1978 -> 1978 bytes .../target/classes/org/example/Main.class | Bin 540 -> 379 bytes .../classes/org/example/UserChoice.class | Bin 6559 -> 7010 bytes 6 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index c216bd0..9081369 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -16,7 +16,7 @@ public Course(String name, double price) { } private static synchronized String generateCourseId() { - return "COURSE-" + (++courseCounter); + return "COURSE-" + (courseCounter++); } public String getName() { diff --git a/ironSchool/src/main/java/org/example/Main.java b/ironSchool/src/main/java/org/example/Main.java index 407f157..ef56760 100644 --- a/ironSchool/src/main/java/org/example/Main.java +++ b/ironSchool/src/main/java/org/example/Main.java @@ -2,6 +2,6 @@ public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + } } \ No newline at end of file diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 753e2c1..346a283 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -115,6 +115,7 @@ private static void collectCourseNames(int courseQuantity) { public static void commandMenu() { while (true) { + System.out.println("\n"); System.out.println("Please select from the following options:"); System.out.println("1. ENROLL"); System.out.println("2. ASSIGN"); @@ -187,6 +188,8 @@ public static void showTeacherNames(){ } } + + public static void showProfit(){ totalProfit = totalStudentEnrollment - (totalCourseCost - totalTeacherSalary); System.out.println(totalProfit); diff --git a/ironSchool/target/classes/org/example/Course.class b/ironSchool/target/classes/org/example/Course.class index c97f853282dcf35baceb4002c3fa3814a05f7034..382d396bb8528c3ce2b82567e4c001dbb160e53b 100644 GIT binary patch delta 32 lcmdnRzl(puA*SgC8;>}$@G>)i0RJWi*+`az%|fgzm;kAj2*&^b delta 32 lcmdnRzl(puA*OzZjYk|=c$pYLfPWK%EK5S% diff --git a/ironSchool/target/classes/org/example/Main.class b/ironSchool/target/classes/org/example/Main.class index 8a26bbede35478ee648da19fff6f147a51234845..3b267cc828032b01c9cdcceb4d2a04be0895b7b3 100644 GIT binary patch delta 164 zcmbQk@|%h4)W2Q(7#J9A8AK*>=`*u4a7?_ot)88M2`I(@BpDf48Q6d%Cy=KPq#1!U ztJZb~#*JWUE+7e#W?*1u;0BUB5CuS*7s%se;A7wiihwk012IS)hDJ6djf@Ne41x>{ NTtJmVK($N^!T?Q^40Qki delta 326 zcmZvYJ5Iw;5Jk^8IF8K&LV^R~o1_XfE-3;%1qD(hdP`VQkYgibKvY>ndNu(?kSJIH zTS7vN?Sh8pj^@t0XGZVadRg(lem*{da|R19n7cG^9X!J-MrhuKk6{pp$s`y*-{;Xx zsHG3N;9r)LX&PK*(klh%wK7+KGCIC?=q%2bb014DMOCn=t8Qx-XcevY$vg5|j(1dxG1Ta)n(6_&>}lt+ o&w)Bc__Tzn_lDD2Te9&7@XBqren`E7bV`cLAxD}Nda4%vUuDNN)Bpeg diff --git a/ironSchool/target/classes/org/example/UserChoice.class b/ironSchool/target/classes/org/example/UserChoice.class index 390cb51ffb2c67c83519872f9f068c2a71e5421f..208f973853ffd8515efcf25252f3b30a0f7e135f 100644 GIT binary patch delta 3810 zcmZu!33yc175;BBGw;pI%Op%l0s+E=gph-PS7)$E!S@Y^!;{sEjS}X~ zIt&R@X)srV64I?Yeu&$QL$=IWQe>BoAIab(nZb!_DGvlg8hUZ3jvvdYs5HN_v$cWt z?>2ThG822zb z02~4d4T1J{e@A0=Q%9GIhsc7aVxLi>c*75qgc)8>WzDMEswx%xIV|>i7WsV3mei;? zK%g_d9^ca1wVv|YHLHA;J{6BJ__Ms8s@mEWYgSs*Dh_gXwk7IYy{4kFW;JCG35=Q( zleOkm9HHh33YDR#z@6Us}0J#V^U>JWJ!sRke$ktyb|QgFBsY*U7=t z#x!;8g}>7AYtzYKOJGYhph4;UvpSxW^T~4FN-0UIx%j+}-^fKxF0SkhY-$auc!A@} zt*s%3&+GN7IAL6`=8Bh${c2wL6$ZvqUgA;ldx}~*gC!nG>}xt+m&B%-#QH*AjZGb) z%8t%JTU$GOQsfUh{wPHfOp&Nn4XOB(jxqSNfQ>|+ui!0WHgoq3I_If)hXR|r8ZK6G zQoz2kHPq0e;yuR0AEXm)OqTa4(a_bwT>21yQ}B_FkMVb-$hp`vh=1z%M5Z=vR|U2- zb(Z^sO&SLAsgBR^Z{t?yG{=8*{1>N;XPuK%h6Li)H){A2!-{||gowLYJ74`$*mPkR z4&x$iktS5(RD`CB1mgiMH%TPw!X=Wpv9*IaX^4bWO+$_t#lj%m#uwW7abh$J$>~$M zsI$}GEsw4yQjA#%^CnOE+L4}Lb(X4Q{2*aCE%j_GrADv5$!JfQVtk@+cg@$t0&%V) z7V?ycGGlw6(;S!P6@|C7v8Qu-FK>^2IXaE?0qVg+QjU$CYV(;Bto*7PTx) zVsUfI^J=y%YGz9g&6aet)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miami@gmail.com" Date: Wed, 26 Jun 2024 23:45:42 -0400 Subject: [PATCH 23/31] create generate studentid method --- .../src/main/java/org/example/Student.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Student.java b/ironSchool/src/main/java/org/example/Student.java index 2b5647e..cc25b17 100644 --- a/ironSchool/src/main/java/org/example/Student.java +++ b/ironSchool/src/main/java/org/example/Student.java @@ -7,20 +7,23 @@ public class Student { private String name; private String address; private String email; - private Course course; + // private Course course; + - // Default constructor - public Student() { - this.studentId = generateStudentId(); - } // Parameterized constructor - public Student(String name, String address, String email) { + public Student(String studentId, String name, String address, String email) { + this.studentId = generateStudentId(); this.name = name; this.address = address; this.email = email; } + public String generateStudentId() { + return UUID.randomUUID().toString(); + + } + // Getter for studentId public String getStudentId() { return studentId; @@ -54,14 +57,14 @@ public void setEmail(String email) { } // Getter and Setter for course - public Course getCourse() { - return course; - } - - public void setCourse(Course course) { - this.course = course; - } + //public Course getCourse() { + // return course; +// } +// +// public void setCourse(Course course) { +// this.course = course; +// } } -} + From 434d95cd84851a1710afea3d1d25a4f9cfc3dab8 Mon Sep 17 00:00:00 2001 From: "axartmiami@gmail.com" Date: Thu, 27 Jun 2024 00:53:43 -0400 Subject: [PATCH 24/31] add student method show student and look up student --- .../src/main/java/org/example/Student.java | 36 ++++++++++++----- .../src/main/java/org/example/UserChoice.java | 40 ++++++++++++++++++- 2 files changed, 65 insertions(+), 11 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Student.java b/ironSchool/src/main/java/org/example/Student.java index cc25b17..a2ac51b 100644 --- a/ironSchool/src/main/java/org/example/Student.java +++ b/ironSchool/src/main/java/org/example/Student.java @@ -1,4 +1,5 @@ package org.example; +import java.util.List; import java.util.UUID; public class Student { @@ -7,7 +8,8 @@ public class Student { private String name; private String address; private String email; - // private Course course; + private Course course; + private List coursesEnrolled; @@ -56,14 +58,30 @@ public void setEmail(String email) { this.email = email; } - // Getter and Setter for course - //public Course getCourse() { - // return course; -// } -// -// public void setCourse(Course course) { -// this.course = course; -// } + //Getter and Setter for course + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } + + + @Override + public String toString() { + StringBuilder details = new StringBuilder(); + details.append("Student Name: ").append(name).append("\n") + .append("Student ID: ").append(studentId).append("\n") + .append("Address: ").append(address).append("\n") + .append("Email: ").append(email).append("\n"); + details.append("Enrolled Courses: ").append(coursesEnrolled.size() > 0 ? "\n" : "None\n"); + + for (Course course : coursesEnrolled) { + details.append(course.getName()).append("\n"); + } + return details.toString(); + } } diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 346a283..53e07c9 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -12,6 +12,7 @@ public class UserChoice { public static double totalStudentEnrollment = 0.0; private static List courses = new ArrayList<>(); private static List teachers = new ArrayList<>(); + private static List students = new ArrayList<>(); public static void main(String[] args) { welcome(); @@ -147,10 +148,10 @@ public static void commandMenu() { // Lookup course logic here break; case 5: - // Show students logic here + showStudentNames(); break; case 6: - // Lookup student logic here + lookupStudent(); break; case 7: showTeacherNames(); @@ -188,6 +189,41 @@ public static void showTeacherNames(){ } } + public static void showStudentNames(){ + System.out.println("Students: "); + for(Student student : students){ + System.out.println(student.getName()); + } + } + + public static void lookupStudent() { + System.out.println("Enter the student ID to lookup:"); + try { + String studentId = scanner.nextLine(); + scanner.nextLine(); // Clear the buffer + + Student student = findStudentById(studentId); + + if (student != null) { + System.out.println(student); // Print full details using Student's toString() method + } else { + System.out.println("Student with ID " + studentId + " not found."); + } + } catch (InputMismatchException e) { + System.out.println("Invalid input. Please enter a valid student ID."); + scanner.next(); // Clear invalid input + } + } + + private static Student findStudentById(String studentId) { + for (Student student : students) { + if (student.getStudentId().equals(studentId)) { + return student; + } + } + return null; // Return null if student not found + } + public static void showProfit(){ From daab9a70b97c8d789e7610d58257260be7555438 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Thu, 27 Jun 2024 01:37:11 -0400 Subject: [PATCH 25/31] add lookup course, student quantity and student info --- .../src/main/java/org/example/Course.java | 17 +++++ .../src/main/java/org/example/Student.java | 2 +- .../src/main/java/org/example/UserChoice.java | 70 +++++++++++++++++- .../target/classes/org/example/Course.class | Bin 1978 -> 2368 bytes .../target/classes/org/example/Student.class | Bin 0 -> 2516 bytes .../classes/org/example/UserChoice.class | Bin 7010 -> 9595 bytes 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 ironSchool/target/classes/org/example/Student.class diff --git a/ironSchool/src/main/java/org/example/Course.java b/ironSchool/src/main/java/org/example/Course.java index 9081369..9335f52 100644 --- a/ironSchool/src/main/java/org/example/Course.java +++ b/ironSchool/src/main/java/org/example/Course.java @@ -8,6 +8,14 @@ public class Course { private double money_earned; private Teacher teacher; + public String getCourseId() { + return courseId; + } + + public void setCourseId(String courseId) { + this.courseId = courseId; + } + public Course(String name, double price) { this.courseId = generateCourseId(); this.name = name; @@ -53,4 +61,13 @@ public void addEarnings(double earnings){ this.money_earned += earnings; } } + + @Override + public String toString() { + + return "Course Name: " + name + "\n" + + "Course ID: " + courseId + "\n" + + "price: " + price + "\n" + + "money_earned: " + money_earned + "\n"; + } } diff --git a/ironSchool/src/main/java/org/example/Student.java b/ironSchool/src/main/java/org/example/Student.java index a2ac51b..5936c27 100644 --- a/ironSchool/src/main/java/org/example/Student.java +++ b/ironSchool/src/main/java/org/example/Student.java @@ -14,7 +14,7 @@ public class Student { // Parameterized constructor - public Student(String studentId, String name, String address, String email) { + public Student(String name, String address, String email) { this.studentId = generateStudentId(); this.name = name; this.address = address; diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 53e07c9..29cce73 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -111,9 +111,49 @@ private static void collectCourseNames(int courseQuantity) { System.out.println(course.getName() + " : $" + course.getPrice()); } System.out.println("Total course cost: $" + totalCourseCost); + studentQuantity(); + } + + public static void studentQuantity(){ + System.out.println("How many students will attend this school?"); + int studentQuantity; + while(true){ + try{ + studentQuantity = scanner.nextInt(); + scanner.nextLine(); + if(studentQuantity > 0){ + break; + } + System.out.println("Enter a number above ZERO"); + } catch (InputMismatchException e){ + System.out.println("Uh oh! please enter a number. "); + scanner.next(); + } + } + collectStudentNames(studentQuantity); commandMenu(); } + + private static void collectStudentNames(int studentQuantity) { + for (int i = 0; i < studentQuantity; i++) { + String name = getFilteredName("student", i); + System.out.println("Enter the address for student " + name + ": "); + String address = scanner.nextLine(); + System.out.println("Enter the email for student " + name + ": "); + String email = scanner.nextLine(); + + Student student = new Student(name, address, email); + students.add(student); + totalStudentEnrollment += 3000; + } + + System.out.println("Student names:"); + for (Student student : students) { + System.out.println(student.getName()); + } + } + public static void commandMenu() { while (true) { System.out.println("\n"); @@ -145,7 +185,7 @@ public static void commandMenu() { showCourses(); break; case 4: - // Lookup course logic here + lookupCourse(); break; case 5: showStudentNames(); @@ -224,6 +264,34 @@ private static Student findStudentById(String studentId) { return null; // Return null if student not found } + public static void lookupCourse() { + System.out.println("Enter the course ID to lookup:"); + try { + String courseId = scanner.nextLine(); + scanner.nextLine(); + + Course course = findCourseById(courseId); + + if (course != null) { + System.out.println(course); + } else { + System.out.println("Course with ID " + courseId + " not found."); + } + } catch (InputMismatchException e) { + System.out.println("Invalid input. Please enter a valid course ID."); + scanner.next(); + } + } + + private static Course findCourseById(String courseId) { + for (Course course : courses) { + if (course.getCourseId().equals(courseId)) { + return course; + } + } + return null; + } + public static void showProfit(){ diff --git a/ironSchool/target/classes/org/example/Course.class b/ironSchool/target/classes/org/example/Course.class index 382d396bb8528c3ce2b82567e4c001dbb160e53b..eff0f544139d4d1c14304db480d76063d4aead9f 100644 GIT binary patch literal 2368 zcmaJ>e^(nt6upy#Bn?X-6hcc&ixx}>ZKJleN`PV$u+a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`tlyt)tnY300_dG$yMxu1Y9Nle2N+U2X zTdfV2iM>HlX$GXL2m|y-;}23xW@uNN3#|J1E)`<-Rh|R zV#9F`k9yU!RgGBQIk^UpV6)e4 zj$W-J`+e0uODfU;+sK0U|{gpH5 zuN(}ntj|LGCm>`Y@IF4EMax|y+E1IW@l=<-f`KbM zGw*wt2~Yza$xw&DhxjP;RUzgrk(pnIh+G><A8>qSL4| z@G%~QzM>gf8qP>@B#}?>>3~QiBTK_XR!HRbIYe|jX(FGE%*fnuMk*tTR0kQ^V<_D` z`C|6vFKohRuP|3M!|sdwHO~5gdu)sQ?5YP5Uim?#@>ul~^pLLN5R;sfHNTH^`4>o6 o|Hk6%HLW$;W(ndyr!9s@_=0PiUmx@T1Yhwj!`;`|!VWI~2a(foQUCw| diff --git a/ironSchool/target/classes/org/example/Student.class b/ironSchool/target/classes/org/example/Student.class new file mode 100644 index 0000000000000000000000000000000000000000..5508d87beeb0faffb952d353483106c782f652be GIT binary patch literal 2516 zcmZ`*T~pge6g_J&GL8tr7$_-COi6>WF%D^(HkgnmKw1amBsCvR`YCMH2#ic+xx@4q z6D(8WP@$-qTM~Z_wKpp-d*Xh|9<-ez-`!J1kk0R zTSX8(0vC3)AGCBuGt23RTRVEu7U-EbOv7Ff=!#Emgb_log0PBnPz467RynO7XnXq= zJzcQtCEcXQKv_3+OS5$k$(977@u}QN?1F6>W;xT#Xy;Y*`j4x4S0)>>t1fT3%@q~z;VRWBR_j(xXM(xYS}ZzfMnPO)q&@F@ zb)!w7FH$OIkY;>se_uDLNh;ncN~fe==u8N+0wNs3`vPhs zdUk0p7QzSA`mU>&Tz*LTmZem3af{k7n^v__(MvHmhuU0B=9^J5kJ|$MZoajK6^g>S5{iiHc8=rP78i`=@FN z47b!I>*3sE1vv$)D)M+p(kFFom@utvt(MmhxFffEDm@;n_zVTvKn~p6lWxDWWb2IA zS<5iiu&Ls6*$GNnw`Hkhp~fj^!6=)WUALIk)iyQe{n}z7BXG;7o}Cr$M5Z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23w>N;HJWp@RQ{0dU9mAav;ku2r1$nvvU zmazqHsF3B>L#SRY6##2QR?u;kn@NcI0E;vXF$N27F{Vx)of%a3v9Ca Date: Thu, 27 Jun 2024 01:53:19 -0400 Subject: [PATCH 26/31] add enrollment --- .../src/main/java/org/example/UserChoice.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 29cce73..c4020a5 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -172,11 +172,11 @@ public static void commandMenu() { try { int choice = scanner.nextInt(); - scanner.nextLine(); // Clear the buffer + scanner.nextLine(); switch (choice) { case 1: - // Enroll logic here + enrollStudent(); break; case 2: // Assign logic here @@ -215,6 +215,27 @@ public static void commandMenu() { } } + public static void enrollStudent() { + System.out.println("Enter a student Id to enroll: "); + String studentId = scanner.nextLine(); + Student student = findStudentById(studentId); + + if(student == null){ + System.out.println("Student with id: " + studentId + " not found!"); + return; + } + + System.out.println("Which course should they be enrolled to? Enter Course Id: "); + String courseId = scanner.nextLine(); + Course course = findCourseById(courseId); + + if(course == null){ + System.out.println("Course with Id: " +courseId + " not found!"); + return; + } + System.out.println("Student: " + student.getName() + " has been enrolled into " +course.getName() + "."); + } + public static void showCourses(){ System.out.println("Courses: "); for(Course course : courses){ From 0ce3fd0d973f3c7379816cfb3cd25dcfcc7c0d55 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Thu, 27 Jun 2024 02:11:50 -0400 Subject: [PATCH 27/31] add assign Teacher --- .../src/main/java/org/example/UserChoice.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index c4020a5..5e6ff39 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -236,6 +236,27 @@ public static void enrollStudent() { System.out.println("Student: " + student.getName() + " has been enrolled into " +course.getName() + "."); } + public static void assignTeacher() { + System.out.println("Enter a Teacher Id to assign: "); + String teacherId = scanner.nextLine(); + Teacher teacher = findTeacherById(teacherId); + + if(teacher == null){ + System.out.println("Teacher with id: " + teacherId + " not found!"); + return; + } + + System.out.println("Which course should they be enrolled to? Enter Course Id: "); + String courseId = scanner.nextLine(); + Course course = findCourseById(courseId); + + if(course == null){ + System.out.println("Course with Id: " +courseId + " not found!"); + return; + } + System.out.println("Teacher: " + teacher.getName() + " has been enrolled into " +course.getName() + "."); + } + public static void showCourses(){ System.out.println("Courses: "); for(Course course : courses){ From de19ac5de3dca7dd8f0e3e8a4b66e5551cb918e6 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Thu, 27 Jun 2024 02:59:40 -0400 Subject: [PATCH 28/31] create test for logic, verify student, teacher and course --- ironSchool/pom.xml | 8 + .../src/main/java/org/example/UserChoice.java | 63 +++--- ironSchool/src/test/java/UserChoiceTest.java | 201 ++++++++++++++++++ 3 files changed, 241 insertions(+), 31 deletions(-) create mode 100644 ironSchool/src/test/java/UserChoiceTest.java diff --git a/ironSchool/pom.xml b/ironSchool/pom.xml index 898e2ac..d215f75 100644 --- a/ironSchool/pom.xml +++ b/ironSchool/pom.xml @@ -13,5 +13,13 @@ 17 UTF-8 + + + junit + junit + 4.13.2 + test + + \ No newline at end of file diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 5e6ff39..1cbfe67 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -10,9 +10,9 @@ public class UserChoice { public static double totalTeacherSalary = 0.0; public static double totalProfit = 0.0; public static double totalStudentEnrollment = 0.0; - private static List courses = new ArrayList<>(); - private static List teachers = new ArrayList<>(); - private static List students = new ArrayList<>(); + public static List courses = new ArrayList<>(); + public static List teachers = new ArrayList<>(); + public static List students = new ArrayList<>(); public static void main(String[] args) { welcome(); @@ -179,7 +179,7 @@ public static void commandMenu() { enrollStudent(); break; case 2: - // Assign logic here +// assignTeacher(); break; case 3: showCourses(); @@ -210,7 +210,7 @@ public static void commandMenu() { } } catch (InputMismatchException e) { System.out.println("Uh oh, please enter a valid number."); - scanner.next(); // Clear invalid input + scanner.next(); } } } @@ -236,26 +236,26 @@ public static void enrollStudent() { System.out.println("Student: " + student.getName() + " has been enrolled into " +course.getName() + "."); } - public static void assignTeacher() { - System.out.println("Enter a Teacher Id to assign: "); - String teacherId = scanner.nextLine(); - Teacher teacher = findTeacherById(teacherId); - - if(teacher == null){ - System.out.println("Teacher with id: " + teacherId + " not found!"); - return; - } - - System.out.println("Which course should they be enrolled to? Enter Course Id: "); - String courseId = scanner.nextLine(); - Course course = findCourseById(courseId); - - if(course == null){ - System.out.println("Course with Id: " +courseId + " not found!"); - return; - } - System.out.println("Teacher: " + teacher.getName() + " has been enrolled into " +course.getName() + "."); - } +// public static void assignTeacher() { +// System.out.println("Enter a Teacher Id to assign: "); +// String teacherId = scanner.nextLine(); +// Teacher teacher = findTeacherById(teacherId); +// +// if(teacher == null){ +// System.out.println("Teacher with id: " + teacherId + " not found!"); +// return; +// } +// +// System.out.println("Which course should they be enrolled to? Enter Course Id: "); +// String courseId = scanner.nextLine(); +// Course course = findCourseById(courseId); +// +// if(course == null){ +// System.out.println("Course with Id: " +courseId + " not found!"); +// return; +// } +// System.out.println("Teacher: " + teacher.getName() + " has been enrolled into " +course.getName() + "."); +// } public static void showCourses(){ System.out.println("Courses: "); @@ -282,28 +282,28 @@ public static void lookupStudent() { System.out.println("Enter the student ID to lookup:"); try { String studentId = scanner.nextLine(); - scanner.nextLine(); // Clear the buffer + scanner.nextLine(); Student student = findStudentById(studentId); if (student != null) { - System.out.println(student); // Print full details using Student's toString() method + System.out.println(student); } else { System.out.println("Student with ID " + studentId + " not found."); } } catch (InputMismatchException e) { System.out.println("Invalid input. Please enter a valid student ID."); - scanner.next(); // Clear invalid input + scanner.next(); } } - private static Student findStudentById(String studentId) { + public static Student findStudentById(String studentId) { for (Student student : students) { if (student.getStudentId().equals(studentId)) { return student; } } - return null; // Return null if student not found + return null; } public static void lookupCourse() { @@ -325,7 +325,7 @@ public static void lookupCourse() { } } - private static Course findCourseById(String courseId) { + public static Course findCourseById(String courseId) { for (Course course : courses) { if (course.getCourseId().equals(courseId)) { return course; @@ -357,4 +357,5 @@ public static Boolean containsNumbers(String input){ Matcher matcher = pattern.matcher(input); return matcher.find(); } + } diff --git a/ironSchool/src/test/java/UserChoiceTest.java b/ironSchool/src/test/java/UserChoiceTest.java new file mode 100644 index 0000000..3ce2297 --- /dev/null +++ b/ironSchool/src/test/java/UserChoiceTest.java @@ -0,0 +1,201 @@ +import static org.junit.Assert.*; + +import org.example.Course; +import org.example.Student; +import org.example.Teacher; +import org.junit.Before; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.PrintStream; +import java.io.ByteArrayOutputStream; +import org.example.UserChoice; +import java.util.ArrayList; +import java.util.List; + +public class UserChoiceTest { + @Test + public void testContainsProfanity() { + assertTrue(UserChoice.containsProfanity("This is a fucking test")); + assertTrue(UserChoice.containsProfanity("You are an asshole")); + assertFalse(UserChoice.containsProfanity("This is a clean test")); + assertFalse(UserChoice.containsProfanity("Hello World!")); + } + + @Test + public void testContainsNumbers() { + assertTrue(UserChoice.containsNumbers("Hello123")); + assertTrue(UserChoice.containsNumbers("123")); + assertFalse(UserChoice.containsNumbers("Hello")); + assertFalse(UserChoice.containsNumbers("No numbers here")); + } + + @Test + public void testShowProfit() { + UserChoice.totalStudentEnrollment = 9000.0; + UserChoice.totalCourseCost = 3000.0; + UserChoice.totalTeacherSalary = 2000.0; + + double expectedProfit = UserChoice.totalStudentEnrollment - (UserChoice.totalCourseCost + UserChoice.totalTeacherSalary); + + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.showProfit(); + + String actualOutput = outContent.toString().trim(); + + System.setOut(System.out); + + assertEquals(String.valueOf(expectedProfit), actualOutput); + } + + @Before + public void setUp() { + UserChoice.courses = new ArrayList<>(); + UserChoice.courses.add(new Course("Math101", 0)); + UserChoice.courses.add(new Course("Science102", 0)); + UserChoice.courses.add(new Course("History103", 0)); + } + + @Test + public void testFindCourseById_CourseExists() { + Course course = UserChoice.findCourseById("Course1"); + assertNotNull(course); + assertEquals("Math101", ((Course) course).getName()); + } + + @Test + public void testFindCourseById_CourseDoesNotExist() { + Course course = UserChoice.findCourseById("NonExistentCourse"); + assertNull(course); + } + + @Test + public void testLookupCourse_CourseDoesNotExist() { + String input = "NonExistentCourse\n"; + ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); + System.setIn(in); + + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.lookupCourse(); + + String expectedOutput = "Course with ID NonExistentCourse not found."; + String actualOutput = outContent.toString().trim(); // Trim to remove any extra newline + + System.setIn(System.in); + System.setOut(System.out); + + assertEquals(expectedOutput, actualOutput); + } + + @Before + public void setUpStudent() { + UserChoice.students = new ArrayList<>(); + UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); + UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); + UserChoice.students.add(new Student("Charlie", "789 Oak Dr", "charlie@example.com")); + + UserChoice.teachers = new ArrayList<>(); + UserChoice.teachers.add(new Teacher("Mr. Smith", 700)); + UserChoice.teachers.add(new Teacher("Ms. Johnson", 800)); + UserChoice.teachers.add(new Teacher("Dr. Brown", 900)); + } + + @Test + public void testFindStudentById_StudentExists() { + Student student = UserChoice.findStudentById("1"); + assertNotNull(student); + assertEquals("Alice", student.getName()); + } + + @Test + public void testFindStudentById_StudentDoesNotExist() { + Student student = UserChoice.findStudentById("NonExistentStudent"); + assertNull(student); + } + + @Before + public void setUpStudentLookUp() { + UserChoice.students = new ArrayList<>(); + UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); + UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); + UserChoice.students.add(new Student("Charlie","789 Oak Dr", "charlie@example.com")); + } + + @Test + public void testLookupStudent_StudentExists() { + String input = "1\n"; + ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); + System.setIn(in); + + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.lookupStudent(); + + String expectedOutput = "Student Name: Alice"; + String actualOutput = outContent.toString().trim(); + System.setIn(System.in); + System.setOut(System.out); + + assertTrue(actualOutput.contains(expectedOutput)); + } + + @Test + public void testLookupStudent_StudentDoesNotExist() { + String input = "4\n"; + ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); + System.setIn(in); + + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.lookupStudent(); + + String expectedOutput = "Student with ID 4 not found."; + String actualOutput = outContent.toString().trim(); + System.setIn(System.in); + System.setOut(System.out); + + assertEquals(expectedOutput, actualOutput); + } + + @Before + public void setUpShowStudent() { + UserChoice.students = new ArrayList<>(); + UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); + UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); + UserChoice.students.add(new Student("Charlie", "789 Oak Dr", "charlie@example.com")); + } + + @Test + public void testShowStudentNames() { + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.showStudentNames(); + + String expectedOutput = "Students: \nAlice\nBob\nCharlie"; + String actualOutput = outContent.toString().trim(); + System.setOut(System.out); + + assertEquals(expectedOutput, actualOutput); + } + + @Test + public void testShowTeacherNames() { + ByteArrayOutputStream outContent = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outContent)); + + UserChoice.showTeacherNames(); + + String expectedOutput = "Teachers: \nMr. Smith\nMs. Johnson\nDr. Brown"; + String actualOutput = outContent.toString().trim(); + System.setOut(System.out); + assertEquals(expectedOutput, actualOutput); + } + +} From 0d2c08189ad63a0f7e7bc269064547397641e8a6 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Thu, 27 Jun 2024 03:10:53 -0400 Subject: [PATCH 29/31] beautify code --- ironSchool/src/test/java/UserChoiceTest.java | 78 ++++++++------------ 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/ironSchool/src/test/java/UserChoiceTest.java b/ironSchool/src/test/java/UserChoiceTest.java index 3ce2297..9873cd5 100644 --- a/ironSchool/src/test/java/UserChoiceTest.java +++ b/ironSchool/src/test/java/UserChoiceTest.java @@ -14,6 +14,27 @@ import java.util.List; public class UserChoiceTest { + @Before + public void setUp() { + // Initialize the courses list + UserChoice.courses = new ArrayList<>(); + UserChoice.courses.add(new Course("Math101", 2000)); + UserChoice.courses.add(new Course("Science102", 2000)); + UserChoice.courses.add(new Course("History103", 2000)); + + // Initialize the students list + UserChoice.students = new ArrayList<>(); + UserChoice.students.add(new Student("Alice","123 Main St", "alice@example.com")); + UserChoice.students.add(new Student("Bob","456 Maple Ave", "bob@example.com")); + UserChoice.students.add(new Student("Charlie","789 Oak Dr", "charlie@example.com")); + + // Initialize the teachers list + UserChoice.teachers = new ArrayList<>(); + UserChoice.teachers.add(new Teacher("Mr. Smith", 700)); + UserChoice.teachers.add(new Teacher("Ms. Johnson", 800)); + UserChoice.teachers.add(new Teacher("Dr. Brown", 900)); + } + @Test public void testContainsProfanity() { assertTrue(UserChoice.containsProfanity("This is a fucking test")); @@ -44,25 +65,16 @@ public void testShowProfit() { UserChoice.showProfit(); String actualOutput = outContent.toString().trim(); - System.setOut(System.out); assertEquals(String.valueOf(expectedProfit), actualOutput); } - @Before - public void setUp() { - UserChoice.courses = new ArrayList<>(); - UserChoice.courses.add(new Course("Math101", 0)); - UserChoice.courses.add(new Course("Science102", 0)); - UserChoice.courses.add(new Course("History103", 0)); - } - @Test public void testFindCourseById_CourseExists() { Course course = UserChoice.findCourseById("Course1"); assertNotNull(course); - assertEquals("Math101", ((Course) course).getName()); + assertEquals("Math101", course.getName()); } @Test @@ -74,8 +86,7 @@ public void testFindCourseById_CourseDoesNotExist() { @Test public void testLookupCourse_CourseDoesNotExist() { String input = "NonExistentCourse\n"; - ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); - System.setIn(in); + System.setIn(new ByteArrayInputStream(input.getBytes())); ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); @@ -83,7 +94,7 @@ public void testLookupCourse_CourseDoesNotExist() { UserChoice.lookupCourse(); String expectedOutput = "Course with ID NonExistentCourse not found."; - String actualOutput = outContent.toString().trim(); // Trim to remove any extra newline + String actualOutput = outContent.toString().trim(); System.setIn(System.in); System.setOut(System.out); @@ -91,19 +102,6 @@ public void testLookupCourse_CourseDoesNotExist() { assertEquals(expectedOutput, actualOutput); } - @Before - public void setUpStudent() { - UserChoice.students = new ArrayList<>(); - UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); - UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); - UserChoice.students.add(new Student("Charlie", "789 Oak Dr", "charlie@example.com")); - - UserChoice.teachers = new ArrayList<>(); - UserChoice.teachers.add(new Teacher("Mr. Smith", 700)); - UserChoice.teachers.add(new Teacher("Ms. Johnson", 800)); - UserChoice.teachers.add(new Teacher("Dr. Brown", 900)); - } - @Test public void testFindStudentById_StudentExists() { Student student = UserChoice.findStudentById("1"); @@ -117,19 +115,10 @@ public void testFindStudentById_StudentDoesNotExist() { assertNull(student); } - @Before - public void setUpStudentLookUp() { - UserChoice.students = new ArrayList<>(); - UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); - UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); - UserChoice.students.add(new Student("Charlie","789 Oak Dr", "charlie@example.com")); - } - @Test public void testLookupStudent_StudentExists() { String input = "1\n"; - ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); - System.setIn(in); + System.setIn(new ByteArrayInputStream(input.getBytes())); ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); @@ -138,6 +127,7 @@ public void testLookupStudent_StudentExists() { String expectedOutput = "Student Name: Alice"; String actualOutput = outContent.toString().trim(); + System.setIn(System.in); System.setOut(System.out); @@ -147,8 +137,7 @@ public void testLookupStudent_StudentExists() { @Test public void testLookupStudent_StudentDoesNotExist() { String input = "4\n"; - ByteArrayInputStream in = new ByteArrayInputStream(input.getBytes()); - System.setIn(in); + System.setIn(new ByteArrayInputStream(input.getBytes())); ByteArrayOutputStream outContent = new ByteArrayOutputStream(); System.setOut(new PrintStream(outContent)); @@ -157,20 +146,13 @@ public void testLookupStudent_StudentDoesNotExist() { String expectedOutput = "Student with ID 4 not found."; String actualOutput = outContent.toString().trim(); + System.setIn(System.in); System.setOut(System.out); assertEquals(expectedOutput, actualOutput); } - @Before - public void setUpShowStudent() { - UserChoice.students = new ArrayList<>(); - UserChoice.students.add(new Student("Alice", "123 Main St", "alice@example.com")); - UserChoice.students.add(new Student("Bob", "456 Maple Ave", "bob@example.com")); - UserChoice.students.add(new Student("Charlie", "789 Oak Dr", "charlie@example.com")); - } - @Test public void testShowStudentNames() { ByteArrayOutputStream outContent = new ByteArrayOutputStream(); @@ -180,6 +162,7 @@ public void testShowStudentNames() { String expectedOutput = "Students: \nAlice\nBob\nCharlie"; String actualOutput = outContent.toString().trim(); + System.setOut(System.out); assertEquals(expectedOutput, actualOutput); @@ -194,8 +177,9 @@ public void testShowTeacherNames() { String expectedOutput = "Teachers: \nMr. Smith\nMs. Johnson\nDr. Brown"; String actualOutput = outContent.toString().trim(); + System.setOut(System.out); + assertEquals(expectedOutput, actualOutput); } - } From 65447d8f30869da749cc5e828c4cde29b19d807c Mon Sep 17 00:00:00 2001 From: Estefanymary Date: Thu, 27 Jun 2024 08:55:19 -0400 Subject: [PATCH 30/31] create teacher lookup --- .../src/main/java/org/example/Teacher.java | 16 ++ .../src/main/java/org/example/UserChoice.java | 145 +++++++++++------- 2 files changed, 102 insertions(+), 59 deletions(-) diff --git a/ironSchool/src/main/java/org/example/Teacher.java b/ironSchool/src/main/java/org/example/Teacher.java index 1f846f1..9a08eda 100644 --- a/ironSchool/src/main/java/org/example/Teacher.java +++ b/ironSchool/src/main/java/org/example/Teacher.java @@ -1,10 +1,12 @@ package org.example; +import java.util.List; import java.util.UUID; public class Teacher { private String teacherId; private String name; private double salary; + private List coursesEnrolled; public Teacher(String name, double salary) { this.teacherId = generateId(); @@ -35,6 +37,20 @@ public double getSalary() { public void setSalary(double salary) { this.salary = salary; } + + @Override + public String toString() { + StringBuilder details = new StringBuilder(); + details.append("teacher Name: ").append(name).append("\n") + .append("teacher ID: ").append(teacherId).append("\n") + .append("Salary: ").append(salary).append("\n"); + details.append("Enrolled Courses: ").append(coursesEnrolled.size() > 0 ? "\n" : "None\n"); + + for (Course course : coursesEnrolled) { + details.append(course.getName()).append("\n"); + } + return details.toString(); + } } diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 1cbfe67..322c27d 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -197,7 +197,7 @@ public static void commandMenu() { showTeacherNames(); break; case 8: - // Lookup teacher logic here + lookupTeacher(); break; case 9: showProfit(); @@ -270,92 +270,119 @@ public static void showTeacherNames(){ System.out.println(teacher.getName()); } } - - public static void showStudentNames(){ - System.out.println("Students: "); - for(Student student : students){ - System.out.println(student.getName()); - } - } - - public static void lookupStudent() { - System.out.println("Enter the student ID to lookup:"); + public static void lookupTeacher() { + System.out.println("Enter the teacher ID to lookup:"); try { - String studentId = scanner.nextLine(); + String teacherId = scanner.nextLine(); scanner.nextLine(); - Student student = findStudentById(studentId); + Teacher teacher = findTeacherById(teacherId); - if (student != null) { - System.out.println(student); + if (teacher != null) { + System.out.println(teacher); } else { - System.out.println("Student with ID " + studentId + " not found."); + System.out.println("Teacher with ID " + teacherId + " not found."); } } catch (InputMismatchException e) { - System.out.println("Invalid input. Please enter a valid student ID."); + System.out.println("Invalid input. Please enter a valid teacher ID."); scanner.next(); } } - public static Student findStudentById(String studentId) { - for (Student student : students) { - if (student.getStudentId().equals(studentId)) { - return student; + public static void showStudentNames () { + System.out.println("Students: "); + for (Student student : students) { + System.out.println(student.getName()); } } - return null; - } - public static void lookupCourse() { - System.out.println("Enter the course ID to lookup:"); - try { - String courseId = scanner.nextLine(); - scanner.nextLine(); + public static void lookupStudent () { + System.out.println("Enter the student ID to lookup:"); + try { + String studentId = scanner.nextLine(); + scanner.nextLine(); - Course course = findCourseById(courseId); + Student student = findStudentById(studentId); - if (course != null) { - System.out.println(course); - } else { - System.out.println("Course with ID " + courseId + " not found."); + if (student != null) { + System.out.println(student); + } else { + System.out.println("Student with ID " + studentId + " not found."); + } + } catch (InputMismatchException e) { + System.out.println("Invalid input. Please enter a valid student ID."); + scanner.next(); } - } catch (InputMismatchException e) { - System.out.println("Invalid input. Please enter a valid course ID."); - scanner.next(); + + } + public static Teacher findTeacherById (String teacherId){ + for (Teacher teacher : teachers) { + if (teacher.getTeacherId().equals(teacherId)) { + return teacher; + } + } + return null; } - } - public static Course findCourseById(String courseId) { - for (Course course : courses) { - if (course.getCourseId().equals(courseId)) { - return course; + public static Student findStudentById (String studentId){ + for (Student student : students) { + if (student.getStudentId().equals(studentId)) { + return student; + } } + return null; } - return null; - } + public static void lookupCourse () { + System.out.println("Enter the course ID to lookup:"); + try { + String courseId = scanner.nextLine(); + scanner.nextLine(); + Course course = findCourseById(courseId); - public static void showProfit(){ - totalProfit = totalStudentEnrollment - (totalCourseCost - totalTeacherSalary); - System.out.println(totalProfit); - } + if (course != null) { + System.out.println(course); + } else { + System.out.println("Course with ID " + courseId + " not found."); + } + } catch (InputMismatchException e) { + System.out.println("Invalid input. Please enter a valid course ID."); + scanner.next(); + } + } + public static Course findCourseById (String courseId){ + for (Course course : courses) { + if (course.getCourseId().equals(courseId)) { + return course; + } + } + return null; + } + + + public static void showProfit () { + totalProfit = totalStudentEnrollment - (totalCourseCost - totalTeacherSalary); + System.out.println(totalProfit); + } - public static Boolean containsProfanity(String input){ - List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); - for (String profanity : profanities) { - if (input.toLowerCase().contains(profanity)) { - return true; + + public static Boolean containsProfanity (String input){ + List profanities = Arrays.asList("fuck", "bitch", "asshole", "cunt"); + for (String profanity : profanities) { + if (input.toLowerCase().contains(profanity)) { + return true; + } } + return false; } - return false; - } - public static Boolean containsNumbers(String input){ - Pattern pattern = Pattern.compile("\\d"); - Matcher matcher = pattern.matcher(input); - return matcher.find(); + public static Boolean containsNumbers (String input){ + Pattern pattern = Pattern.compile("\\d"); + Matcher matcher = pattern.matcher(input); + return matcher.find(); + } } -} + From 463359d591ad092e75386504582ba42c272604b2 Mon Sep 17 00:00:00 2001 From: nomadriding Date: Thu, 27 Jun 2024 08:59:50 -0400 Subject: [PATCH 31/31] add assign --- .../src/main/java/org/example/UserChoice.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/ironSchool/src/main/java/org/example/UserChoice.java b/ironSchool/src/main/java/org/example/UserChoice.java index 322c27d..cb35ad1 100644 --- a/ironSchool/src/main/java/org/example/UserChoice.java +++ b/ironSchool/src/main/java/org/example/UserChoice.java @@ -179,7 +179,7 @@ public static void commandMenu() { enrollStudent(); break; case 2: -// assignTeacher(); + assignTeacher(); break; case 3: showCourses(); @@ -236,26 +236,26 @@ public static void enrollStudent() { System.out.println("Student: " + student.getName() + " has been enrolled into " +course.getName() + "."); } -// public static void assignTeacher() { -// System.out.println("Enter a Teacher Id to assign: "); -// String teacherId = scanner.nextLine(); -// Teacher teacher = findTeacherById(teacherId); -// -// if(teacher == null){ -// System.out.println("Teacher with id: " + teacherId + " not found!"); -// return; -// } -// -// System.out.println("Which course should they be enrolled to? Enter Course Id: "); -// String courseId = scanner.nextLine(); -// Course course = findCourseById(courseId); -// -// if(course == null){ -// System.out.println("Course with Id: " +courseId + " not found!"); -// return; -// } -// System.out.println("Teacher: " + teacher.getName() + " has been enrolled into " +course.getName() + "."); -// } + public static void assignTeacher() { + System.out.println("Enter a Teacher Id to assign: "); + String teacherId = scanner.nextLine(); + Teacher teacher = findTeacherById(teacherId); + + if(teacher == null){ + System.out.println("Teacher with id: " + teacherId + " not found!"); + return; + } + + System.out.println("Which course should they be enrolled to? Enter Course Id: "); + String courseId = scanner.nextLine(); + Course course = findCourseById(courseId); + + if(course == null){ + System.out.println("Course with Id: " +courseId + " not found!"); + return; + } + System.out.println("Teacher: " + teacher.getName() + " has been enrolled into " +course.getName() + "."); + } public static void showCourses(){ System.out.println("Courses: ");