Skip to content

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
merged 105 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
8cc92d0
Create README.md
AmiyahJo Sep 24, 2024
50b1861
Delete lesson_00/amiyahjones/README.md
AmiyahJo Sep 24, 2024
27d57c0
Merge branch 'code-differently:main' into main
AmiyahJo Sep 25, 2024
fa3c700
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
7c2d053
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
faedd1b
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
19a4187
Merge branch 'code-differently:main' into main
AmiyahJo Sep 26, 2024
7711266
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
9a10c4c
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
3ea50c4
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
d7b772d
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
de46b67
Merge branch 'code-differently:main' into main
AmiyahJo Sep 27, 2024
b891561
Merge branch 'code-differently:main' into main
AmiyahJo Sep 28, 2024
7c9f2db
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
ff3ba35
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
457feea
Merge branch 'code-differently:main' into main
AmiyahJo Sep 30, 2024
5868f9d
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
28eacd4
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
bca4933
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
9ff0f9e
Merge branch 'code-differently:main' into main
AmiyahJo Oct 1, 2024
8d02849
Merge branch 'code-differently:main' into main
AmiyahJo Oct 2, 2024
6dd3a43
Merge branch 'code-differently:main' into main
AmiyahJo Oct 2, 2024
95f56a5
Merge branch 'code-differently:main' into main
AmiyahJo Oct 3, 2024
0f4dbac
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
a3b9984
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
54cd199
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
edbe7c0
Merge branch 'code-differently:main' into main
AmiyahJo Oct 4, 2024
7f0a084
Merge branch 'code-differently:main' into main
AmiyahJo Oct 7, 2024
a905b74
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
2d69531
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
df48fbd
Merge branch 'code-differently:main' into main
AmiyahJo Oct 8, 2024
c972d14
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
bc3907c
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
c3eabbb
Merge branch 'code-differently:main' into main
AmiyahJo Oct 9, 2024
9fff7d0
Merge branch 'code-differently:main' into main
AmiyahJo Oct 11, 2024
4c57926
Merge branch 'code-differently:main' into main
AmiyahJo Oct 11, 2024
8dd5d42
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
18f65ee
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
2dd1645
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
0de8601
Merge branch 'code-differently:main' into main
AmiyahJo Oct 14, 2024
85dd364
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
0afda26
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
f31e8d9
Merge branch 'code-differently:main' into main
AmiyahJo Oct 16, 2024
3e24069
Merge branch 'code-differently:main' into main
AmiyahJo Oct 17, 2024
8600f6c
Merge branch 'code-differently:main' into main
AmiyahJo Oct 17, 2024
563b076
Merge branch 'code-differently:main' into main
AmiyahJo Oct 18, 2024
b01a324
Merge branch 'code-differently:main' into main
AmiyahJo Oct 18, 2024
697a72d
Merge branch 'code-differently:main' into main
AmiyahJo Oct 21, 2024
92891f6
Merge branch 'code-differently:main' into main
AmiyahJo Oct 21, 2024
17fdee5
Merge branch 'code-differently:main' into main
AmiyahJo Oct 22, 2024
cf7e6f2
Merge branch 'code-differently:main' into main
AmiyahJo Oct 23, 2024
a131bdc
Merge branch 'code-differently:main' into main
AmiyahJo Oct 23, 2024
c46d32f
Merge branch 'code-differently:main' into main
AmiyahJo Oct 24, 2024
651fa01
Merge branch 'code-differently:main' into main
AmiyahJo Oct 26, 2024
e075fb7
Merge branch 'code-differently:main' into main
AmiyahJo Oct 27, 2024
ec7c3d1
Merge branch 'code-differently:main' into main
AmiyahJo Oct 28, 2024
186c10e
Merge branch 'code-differently:main' into main
AmiyahJo Oct 29, 2024
e13bae6
Merge remote-tracking branch 'refs/remotes/origin/main'
Oct 30, 2024
8f999c6
Merge remote-tracking branch 'refs/remotes/origin/main'
Oct 30, 2024
972daca
feat: adds java class
Oct 30, 2024
1f51dec
rm: old classname
Oct 30, 2024
9a3949d
chore: pascal case
Oct 30, 2024
58d784b
feat: adds 5 variables
Oct 30, 2024
e2c5a69
feat: adds boolean isSuccessful
Oct 30, 2024
ae8787a
fix: Pascal case JobReadinessLab
Oct 30, 2024
dac021b
feat: adds students
Oct 30, 2024
475329e
chore: remove comments
Oct 30, 2024
7558639
feat: adds package
Oct 30, 2024
3219758
feat: adds enum type , jobreadinesslab constructor
Oct 31, 2024
5607445
feat: adds 'this' to disambiguate my variables
Oct 31, 2024
af61d6a
chore: move strings in one line
Oct 31, 2024
10ccc03
feat: adds two member functions
Oct 31, 2024
7964aad
chore: remove 'private' status fom the empty students list
Oct 31, 2024
61c36b2
feat: adds more member variables
Oct 31, 2024
c5ab0f1
fix: changed member function getStudentCount to countStudents
Oct 31, 2024
715f697
chore: whitespace edit
Oct 31, 2024
5ec8ba5
chore: whitespace adjustment
Oct 31, 2024
7107224
feat: adds custom exception
Oct 31, 2024
939fea9
feat: adds tests
Oct 31, 2024
282eeec
chore: comment out class objects
Oct 31, 2024
7331605
rm: JobReadinessLab class file
Oct 31, 2024
cf3fd5f
fix: rename test to JobReadinessProgram
Oct 31, 2024
e2486f0
chore: whitespace
Oct 31, 2024
4335446
rm: student exception
Oct 31, 2024
15d5051
feat: adds tests and corresponding variables in my class
Oct 31, 2024
29599fb
fix: parameters adjusted
Oct 31, 2024
c775b6c
feat: adds isSuccessful method
Oct 31, 2024
69dba6a
feat: adds lecturePerWeek tests and variable
Oct 31, 2024
18424f5
feat: adds getMentor and getSocialSupport
Nov 1, 2024
15d2f54
fix: chaged assigned ta from hashmap back to an array list
Nov 1, 2024
d611983
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo Nov 1, 2024
75ca4b7
feat: adds displayStudents
Nov 1, 2024
ec8b685
feat: adds custom exception
Nov 1, 2024
11b0e7e
fix: apply throw exception to addStudent tests
Nov 1, 2024
8ac09c4
feat: initialized MAX_CAPACITY , adds an if statement for conditional…
Nov 1, 2024
8fdc104
feat: adds tests
Nov 1, 2024
11bf11d
fix: organization
Nov 1, 2024
2b58599
fix: tests from failure to success
Nov 1, 2024
321b240
fix: spotless apply
Nov 1, 2024
4d3837a
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo Nov 1, 2024
e9b0bc1
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo Nov 3, 2024
41dbc1d
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo Nov 5, 2024
e4f94fe
Merge branch 'code-differently:main' into feature/lesson_16
AmiyahJo Nov 5, 2024
b9d5623
fix: changes method in jobReadinessprogram to getLecturesPerWeek()
Nov 5, 2024
802cbc5
chore: spotless apply
Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
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 getLecturesPerWeek() {
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;
}
}
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(Level.Beginner, false, "rich");

// Act
program.addStudent("John");

// Assert
assertEquals(program.getStudentCount(), 1);
}

@Test
void testGetStudentCount() throws ClassroomFullException {
// Arrange
JobReadinessProgram program = new JobReadinessProgram(Level.Advanced, true, "vicente");
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, "vicente");
String result = student.checkReadiness();
assertEquals("Ready for job applications!", result);
}

@Test
void testVerifyIfSuccessful() {
JobReadinessProgram graduate = new JobReadinessProgram(Level.Intermediate, true, "rich");

var graduation = graduate.verifyIsSuccessful();
assertEquals(true, graduation);
}

@Test
void testLecturePerWeek() {
JobReadinessProgram program = new JobReadinessProgram(Level.Advanced, true, "rich");
var lecturesAttended = program.getLecturesPerWeek();
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();
}
}