-
Notifications
You must be signed in to change notification settings - Fork 25
Feat: adds amiyah jones' custom class / exception / objects , lesson 16 #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
VicenteVigueras
merged 105 commits into
code-differently:main
from
AmiyahJo:feature/lesson_16
Nov 6, 2024
Merged
Changes from 103 commits
Commits
Show all changes
105 commits
Select commit
Hold shift + click to select a range
8cc92d0
Create README.md
AmiyahJo 50b1861
Delete lesson_00/amiyahjones/README.md
AmiyahJo 27d57c0
Merge branch 'code-differently:main' into main
AmiyahJo fa3c700
Merge branch 'code-differently:main' into main
AmiyahJo 7c2d053
Merge branch 'code-differently:main' into main
AmiyahJo faedd1b
Merge branch 'code-differently:main' into main
AmiyahJo 19a4187
Merge branch 'code-differently:main' into main
AmiyahJo 7711266
Merge branch 'code-differently:main' into main
AmiyahJo 9a10c4c
Merge branch 'code-differently:main' into main
AmiyahJo 3ea50c4
Merge branch 'code-differently:main' into main
AmiyahJo d7b772d
Merge branch 'code-differently:main' into main
AmiyahJo de46b67
Merge branch 'code-differently:main' into main
AmiyahJo b891561
Merge branch 'code-differently:main' into main
AmiyahJo 7c9f2db
Merge branch 'code-differently:main' into main
AmiyahJo ff3ba35
Merge branch 'code-differently:main' into main
AmiyahJo 457feea
Merge branch 'code-differently:main' into main
AmiyahJo 5868f9d
Merge branch 'code-differently:main' into main
AmiyahJo 28eacd4
Merge branch 'code-differently:main' into main
AmiyahJo bca4933
Merge branch 'code-differently:main' into main
AmiyahJo 9ff0f9e
Merge branch 'code-differently:main' into main
AmiyahJo 8d02849
Merge branch 'code-differently:main' into main
AmiyahJo 6dd3a43
Merge branch 'code-differently:main' into main
AmiyahJo 95f56a5
Merge branch 'code-differently:main' into main
AmiyahJo 0f4dbac
Merge branch 'code-differently:main' into main
AmiyahJo a3b9984
Merge branch 'code-differently:main' into main
AmiyahJo 54cd199
Merge branch 'code-differently:main' into main
AmiyahJo edbe7c0
Merge branch 'code-differently:main' into main
AmiyahJo 7f0a084
Merge branch 'code-differently:main' into main
AmiyahJo a905b74
Merge branch 'code-differently:main' into main
AmiyahJo 2d69531
Merge branch 'code-differently:main' into main
AmiyahJo df48fbd
Merge branch 'code-differently:main' into main
AmiyahJo c972d14
Merge branch 'code-differently:main' into main
AmiyahJo bc3907c
Merge branch 'code-differently:main' into main
AmiyahJo c3eabbb
Merge branch 'code-differently:main' into main
AmiyahJo 9fff7d0
Merge branch 'code-differently:main' into main
AmiyahJo 4c57926
Merge branch 'code-differently:main' into main
AmiyahJo 8dd5d42
Merge branch 'code-differently:main' into main
AmiyahJo 18f65ee
Merge branch 'code-differently:main' into main
AmiyahJo 2dd1645
Merge branch 'code-differently:main' into main
AmiyahJo 0de8601
Merge branch 'code-differently:main' into main
AmiyahJo 85dd364
Merge branch 'code-differently:main' into main
AmiyahJo 0afda26
Merge branch 'code-differently:main' into main
AmiyahJo f31e8d9
Merge branch 'code-differently:main' into main
AmiyahJo 3e24069
Merge branch 'code-differently:main' into main
AmiyahJo 8600f6c
Merge branch 'code-differently:main' into main
AmiyahJo 563b076
Merge branch 'code-differently:main' into main
AmiyahJo b01a324
Merge branch 'code-differently:main' into main
AmiyahJo 697a72d
Merge branch 'code-differently:main' into main
AmiyahJo 92891f6
Merge branch 'code-differently:main' into main
AmiyahJo 17fdee5
Merge branch 'code-differently:main' into main
AmiyahJo cf7e6f2
Merge branch 'code-differently:main' into main
AmiyahJo a131bdc
Merge branch 'code-differently:main' into main
AmiyahJo c46d32f
Merge branch 'code-differently:main' into main
AmiyahJo 651fa01
Merge branch 'code-differently:main' into main
AmiyahJo e075fb7
Merge branch 'code-differently:main' into main
AmiyahJo ec7c3d1
Merge branch 'code-differently:main' into main
AmiyahJo 186c10e
Merge branch 'code-differently:main' into main
AmiyahJo e13bae6
Merge remote-tracking branch 'refs/remotes/origin/main'
8f999c6
Merge remote-tracking branch 'refs/remotes/origin/main'
972daca
feat: adds java class
1f51dec
rm: old classname
9a3949d
chore: pascal case
58d784b
feat: adds 5 variables
e2c5a69
feat: adds boolean isSuccessful
ae8787a
fix: Pascal case JobReadinessLab
dac021b
feat: adds students
475329e
chore: remove comments
7558639
feat: adds package
3219758
feat: adds enum type , jobreadinesslab constructor
5607445
feat: adds 'this' to disambiguate my variables
af61d6a
chore: move strings in one line
10ccc03
feat: adds two member functions
7964aad
chore: remove 'private' status fom the empty students list
61c36b2
feat: adds more member variables
c5ab0f1
fix: changed member function getStudentCount to countStudents
715f697
chore: whitespace edit
5ec8ba5
chore: whitespace adjustment
7107224
feat: adds custom exception
939fea9
feat: adds tests
282eeec
chore: comment out class objects
7331605
rm: JobReadinessLab class file
cf3fd5f
fix: rename test to JobReadinessProgram
e2486f0
chore: whitespace
4335446
rm: student exception
15d5051
feat: adds tests and corresponding variables in my class
29599fb
fix: parameters adjusted
c775b6c
feat: adds isSuccessful method
69dba6a
feat: adds lecturePerWeek tests and variable
18424f5
feat: adds getMentor and getSocialSupport
15d2f54
fix: chaged assigned ta from hashmap back to an array list
d611983
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo 75ca4b7
feat: adds displayStudents
ec8b685
feat: adds custom exception
11b0e7e
fix: apply throw exception to addStudent tests
8ac09c4
feat: initialized MAX_CAPACITY , adds an if statement for conditional…
8fdc104
feat: adds tests
11bf11d
fix: organization
2b58599
fix: tests from failure to success
321b240
fix: spotless apply
4d3837a
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo e9b0bc1
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo 41dbc1d
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo e4f94fe
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo b9d5623
fix: changes method in jobReadinessprogram to getLecturesPerWeek()
802cbc5
chore: spotless apply
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
...ts_app/src/main/java/com/codedifferently/lesson16/amiyahjones/ClassroomFullException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.codedifferently.lesson16.amiyahjones; | ||
|
||
public class ClassroomFullException extends Exception { | ||
public ClassroomFullException(String message) { | ||
super(message); | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
...jects_app/src/main/java/com/codedifferently/lesson16/amiyahjones/JobReadinessProgram.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.codedifferently.lesson16.amiyahjones; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class JobReadinessProgram { | ||
private final boolean isSuccessful; | ||
ArrayList<String> students; | ||
private final Level readinessLevel; | ||
private final int lecturePerWeek; | ||
private static final ArrayList<String> teacherAssistants = new ArrayList<>(); | ||
private String assignedTA; | ||
private final String mentor; | ||
private final String socialSupport; | ||
private final int MAX_CAPACITY = 22; | ||
|
||
static { | ||
teacherAssistants.add("Rich"); | ||
teacherAssistants.add("Vicente"); | ||
teacherAssistants.add("Jordan"); | ||
} | ||
|
||
enum Level { | ||
Beginner, | ||
Intermediate, | ||
Advanced | ||
} | ||
|
||
public JobReadinessProgram(Level readinessLevel, boolean isSuccessful, String assignedTA) { | ||
students = new ArrayList<>(); | ||
this.readinessLevel = readinessLevel; | ||
this.isSuccessful = isSuccessful; | ||
lecturePerWeek = 3; | ||
mentor = "Anthony"; | ||
socialSupport = "Estelle"; | ||
if (teacherAssistants.contains(assignedTA)) { | ||
this.assignedTA = assignedTA; | ||
} | ||
} | ||
|
||
public void addStudent(String studentName) throws ClassroomFullException { | ||
int classroomCheck = students.size(); | ||
if (classroomCheck == MAX_CAPACITY) { | ||
throw new ClassroomFullException("Classroom is full"); | ||
} | ||
students.add(studentName); | ||
} | ||
|
||
public int getStudentCount() { | ||
int count = students.size(); | ||
System.out.println("Total students enrolled: " + count); | ||
return count; | ||
} | ||
|
||
public void displayStudents() { | ||
for (String student : students) { | ||
System.out.println(student); | ||
} | ||
} | ||
|
||
public String checkReadiness() { | ||
return (readinessLevel == Level.Beginner) | ||
? "Needs more training." | ||
: "Ready for job applications!"; | ||
} | ||
|
||
public int lecturePerWeek() { | ||
System.out.println("Number of lectures students have: "); | ||
return lecturePerWeek; | ||
} | ||
|
||
public String getMentor() { | ||
return mentor; | ||
} | ||
|
||
public String getSocialSupport() { | ||
return socialSupport; | ||
} | ||
|
||
public List<String> getTeacherAssistants() { | ||
return new ArrayList<>(teacherAssistants); | ||
} | ||
|
||
public boolean assignTA(String taName) { | ||
if (teacherAssistants.contains(taName)) { | ||
this.assignedTA = taName; | ||
return true; | ||
} else { | ||
throw new IllegalArgumentException("Not a TA. Please choose from: " + getTeacherAssistants()); | ||
} | ||
} | ||
|
||
public void displayAssignedTA() { | ||
if (assignedTA != null) { | ||
System.out.println("Assigned Teacher Assistant: " + assignedTA); | ||
} else { | ||
System.out.println("No Teacher Assistant assigned."); | ||
} | ||
} | ||
|
||
public Boolean verifyIsSuccessful() { | ||
if (isSuccessful) { | ||
System.out.println("Congraulations! You made it through your journey!"); | ||
} else { | ||
System.out.println("At least you got to know what software engineering is like!"); | ||
} | ||
return isSuccessful; | ||
} | ||
} |
133 changes: 133 additions & 0 deletions
133
...s_app/src/test/java/com/codedifferently/lesson16/amiyahjones/JobReadinessProgramTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package com.codedifferently.lesson16.amiyahjones; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import com.codedifferently.lesson16.amiyahjones.JobReadinessProgram.Level; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class JobReadinessProgramTest { | ||
|
||
@Test | ||
void testAddStudent() throws ClassroomFullException { | ||
// Arrange | ||
JobReadinessProgram program = new JobReadinessProgram(null, false, "rich"); | ||
|
||
// Act | ||
program.addStudent("John"); | ||
|
||
// Assert | ||
assertEquals(program.getStudentCount(), 1); | ||
} | ||
|
||
@Test | ||
void testGetStudentCount() throws ClassroomFullException { | ||
// Arrange | ||
JobReadinessProgram program = new JobReadinessProgram(null, true, null); | ||
program.addStudent("John"); | ||
|
||
// Act | ||
int actualCount = program.getStudentCount(); | ||
|
||
// Assert | ||
int expectedCount = 1; | ||
assertEquals(expectedCount, actualCount); | ||
} | ||
|
||
@Test | ||
void testClassroomFullException() { | ||
// Arrange | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Beginner, true, "Jordan"); | ||
|
||
// Act | ||
try { | ||
for (int i = 1; i <= 23; i++) { | ||
program.addStudent("Student " + i); | ||
} | ||
} catch (ClassroomFullException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
|
||
// Assert | ||
int currentCount = program.getStudentCount(); | ||
assert (currentCount == 22); | ||
} | ||
|
||
@Test | ||
void testCheckReadinessBeginner() { | ||
JobReadinessProgram student = new JobReadinessProgram(Level.Beginner, true, null); | ||
String result = student.checkReadiness(); | ||
assertEquals("Needs more training.", result); | ||
} | ||
|
||
@Test | ||
void testCheckReadinessIntermediate() { | ||
JobReadinessProgram student = new JobReadinessProgram(Level.Intermediate, true, null); | ||
String result = student.checkReadiness(); | ||
assertEquals("Ready for job applications!", result); | ||
} | ||
|
||
@Test | ||
void testCheckReadinessAdvanced() { | ||
JobReadinessProgram student = new JobReadinessProgram(Level.Advanced, true, null); | ||
String result = student.checkReadiness(); | ||
assertEquals("Ready for job applications!", result); | ||
} | ||
|
||
@Test | ||
void testVerifyIfSuccessful() { | ||
JobReadinessProgram graduate = new JobReadinessProgram(null, true, "rich"); | ||
|
||
var graduation = graduate.verifyIsSuccessful(); | ||
assertEquals(true, graduation); | ||
} | ||
|
||
@Test | ||
void testLecturePerWeek() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Advanced, true, "rich"); | ||
var lecturesAttended = program.lecturePerWeek(); | ||
assertEquals(3, lecturesAttended); | ||
} | ||
|
||
@Test | ||
void testGetMentor() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Beginner, true, "jordan"); | ||
var AssignedMentor = program.getMentor(); | ||
assertEquals("Anthony", AssignedMentor); | ||
} | ||
|
||
@Test | ||
void testGetSocialSupport() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Beginner, true, "vicente"); | ||
var SocialSupport = program.getSocialSupport(); | ||
assertEquals("Estelle", SocialSupport); | ||
} | ||
|
||
@Test | ||
void testGetTeacherAssistants() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Beginner, true, "vicente"); | ||
var teacherAssitant = program.getTeacherAssistants(); | ||
assertEquals(program.getTeacherAssistants(), teacherAssitant); | ||
} | ||
|
||
@Test | ||
void testAssignTA() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Beginner, true, "Jordan"); | ||
boolean result = program.assignTA("Vicente"); | ||
assert (result == true); | ||
|
||
try { | ||
program.assignTA("Invalid TA"); | ||
} catch (IllegalArgumentException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
} | ||
|
||
@Test | ||
void testDisplayAssignedTA() { | ||
JobReadinessProgram program = new JobReadinessProgram(Level.Advanced, true, "rich"); | ||
program.displayAssignedTA(); | ||
|
||
JobReadinessProgram emptyProgram = new JobReadinessProgram(Level.Beginner, true, "Invalid TA"); | ||
emptyProgram.displayAssignedTA(); | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.