Skip to content

Commit 5a54a0c

Browse files
authored
Merge branch 'code-differently:main' into DavidSmith-Lesson16
2 parents 00e3f6a + 03d2a45 commit 5a54a0c

File tree

424 files changed

+53385
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

424 files changed

+53385
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Lesson 26 Java Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_26/api/java/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Set up JDK 17
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '17'
24+
distribution: 'temurin'
25+
26+
- name: Build Lesson 26 with Java
27+
working-directory: ./lesson_26/api/java
28+
run: ./gradlew check
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Check Lesson 26 TS Pull Request
2+
3+
on:
4+
pull_request:
5+
branches: [ "main" ]
6+
paths:
7+
- "lesson_26/api/javascript/api_app/**"
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Use Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.x'
23+
24+
- name: Build Lesson 26 with Node.js
25+
working-directory: ./lesson_26/api/javascript/api_app
26+
run: |
27+
npm ci
28+
npm run check
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.footballteamobject;
2+
3+
public class DuplicatePlayerException extends Exception {
4+
public DuplicatePlayerException(String message) {
5+
super(message);
6+
}
7+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package com.codedifferently.footballteamobject;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
public class FootballTeam {
7+
8+
public static class DuplicatePlayerException extends Exception {
9+
public DuplicatePlayerException(String message) {
10+
super(message);
11+
}
12+
}
13+
14+
private int playerCount;
15+
private int jerseyNumber50AndOver;
16+
private int jerseyNumberUnder50;
17+
private Map<Integer, String> players = new HashMap<>();
18+
private final String teamName;
19+
private final String location;
20+
private final Conference conference;
21+
22+
public FootballTeam(
23+
String teamName, String location, Conference conference, Map<Integer, String> players) {
24+
this.teamName = teamName;
25+
this.location = location;
26+
this.conference = conference;
27+
this.players = players;
28+
}
29+
30+
public enum Conference {
31+
// Power Five Conferences
32+
ACC,
33+
BIG_12,
34+
BIG_10,
35+
PAC_12,
36+
SEC,
37+
// Group of Five Conferences
38+
AMERICAN,
39+
CONFERENCE_USA,
40+
MAC,
41+
MOUNTAIN_WEST,
42+
SUN_BELT
43+
}
44+
45+
public boolean isPowerFive() {
46+
if (conference == Conference.ACC
47+
|| conference == Conference.BIG_12
48+
|| conference == Conference.BIG_10
49+
|| conference == Conference.PAC_12
50+
|| conference == Conference.SEC) {
51+
return true;
52+
}
53+
return false;
54+
}
55+
56+
public String getTeamName() {
57+
return teamName;
58+
}
59+
60+
public String getLocation() {
61+
return location;
62+
}
63+
64+
public Conference getConference() {
65+
return conference;
66+
}
67+
68+
public int getPlayerCount() {
69+
return playerCount;
70+
}
71+
72+
public Map<Integer, String> getPlayers() {
73+
return players;
74+
}
75+
76+
public void addPlayer(int number, String name) throws DuplicatePlayerException {
77+
if (players.containsKey(number)) {
78+
throw new DuplicatePlayerException("A player with that number already exists.");
79+
}
80+
players.put(number, name);
81+
playerCount++;
82+
}
83+
84+
public void removePlayer(int number) {
85+
players.remove(number);
86+
playerCount--;
87+
}
88+
89+
public void tallyJerseyNumbers() {
90+
for (Map.Entry<Integer, String> entry : players.entrySet()) {
91+
if (entry.getKey() < 50) {
92+
jerseyNumberUnder50++;
93+
} else {
94+
jerseyNumber50AndOver++;
95+
}
96+
}
97+
}
98+
99+
public int getJerseyNumber50AndOver() {
100+
return jerseyNumber50AndOver;
101+
}
102+
103+
public int getJerseyNumberUnder50() {
104+
return jerseyNumberUnder50;
105+
}
106+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package com.codedifferently.lesson16.horseStable;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class HorseStable {
7+
8+
public enum StableType {
9+
PRIVATE,
10+
COMMERCIAL,
11+
RACE,
12+
SHOW
13+
}
14+
15+
private final String name;
16+
private final String location;
17+
private final int capacity;
18+
private final StableType stableType;
19+
private final List<String> horses;
20+
21+
// constructur
22+
public HorseStable(String name, String location, int capacity, StableType stableType) {
23+
this.name = name;
24+
this.location = location;
25+
this.capacity = capacity;
26+
this.stableType = stableType;
27+
this.horses = new ArrayList<>();
28+
}
29+
30+
// getters & setters
31+
public String getName() {
32+
return name;
33+
}
34+
35+
public String getLocation() {
36+
return location;
37+
}
38+
39+
public int getCapacity() {
40+
return capacity;
41+
}
42+
43+
public StableType getStableType() {
44+
return stableType;
45+
}
46+
47+
public List<String> getHorses() {
48+
return horses;
49+
}
50+
51+
// methods
52+
public String stableFull() {
53+
if (horses.size() >= capacity) {
54+
return "The stable is full. Cannot add more horses.";
55+
} else {
56+
return "Space available in the stable.";
57+
}
58+
}
59+
60+
public void addHorse(String horseName) throws StableFullException {
61+
if (horses.size() >= capacity) {
62+
throw new StableFullException("Cannot add horse: stable is at full capacity!");
63+
}
64+
horses.add(horseName);
65+
}
66+
67+
public void removeHorse(String horseName) {
68+
if (!horses.contains(horseName)) {
69+
throw new IllegalArgumentException("Horse not found in the stable.");
70+
}
71+
horses.remove(horseName);
72+
}
73+
74+
public String displayHorses() {
75+
if (horses.isEmpty()) {
76+
return "No horses in the stable.";
77+
}
78+
return "There are " + horses.size() + " horses in " + name + ".";
79+
}
80+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.lesson16.horseStable;
2+
3+
public class StableFullException extends Exception {
4+
public StableFullException(String message) {
5+
super(message);
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.lesson16.KimberleeObject;
2+
3+
public class ConnectionNotFoundException extends Exception {
4+
public ConnectionNotFoundException(String message) {
5+
super(message);
6+
}
7+
}

0 commit comments

Comments
 (0)