Skip to content

Commit b109574

Browse files
committed
feat: merging commit
2 parents 2d71735 + 3f1bfc4 commit b109574

File tree

95 files changed

+8737
-1
lines changed

Some content is hidden

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

95 files changed

+8737
-1
lines changed
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+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
package com.codedifferently.lesson16.KimberleeObject;
2+
3+
import java.util.Arrays;
4+
5+
public class HeadPhones {
6+
7+
private int volume = 0;
8+
private boolean isPoweredOn = false;
9+
private HeadPhoneColor headPhoneColor = HeadPhoneColor.BLACK;
10+
private boolean isWireless = true;
11+
private String brands = "Beats";
12+
boolean isPreferredBrand = BrandUtils.isPreferredBrand(brands);
13+
private boolean isConnectedToBluetooth = false;
14+
15+
public enum BoostMode {
16+
BASS_BOOST,
17+
VOCAL_BOOST,
18+
TREBLE_BOOST;
19+
}
20+
21+
private BoostMode currentMode;
22+
private BoostMode[] modes = BoostMode.values();
23+
private int currentModeIndex = 0;
24+
25+
public HeadPhones() {
26+
this.currentMode = BoostMode.BASS_BOOST;
27+
System.out.println("Constructor called: currentMode set to " + currentMode);
28+
}
29+
30+
public void nextBoostMode() {
31+
currentModeIndex = (currentModeIndex + 1) % modes.length;
32+
currentMode = modes[currentModeIndex];
33+
}
34+
35+
public BoostMode getCurrentMode() {
36+
System.out.println("getCurrentMode called: currentMode is " + currentMode);
37+
return currentMode;
38+
}
39+
40+
public enum HeadPhoneColor {
41+
RED,
42+
BLUE,
43+
ROSEGOLD,
44+
PINK,
45+
WHITE,
46+
BLACK;
47+
}
48+
49+
public void BrandsArray() {
50+
String[] brands = new String[5];
51+
brands[0] = "Beats";
52+
brands[1] = "Sony";
53+
brands[2] = "Bose";
54+
brands[3] = "SkullCandy";
55+
brands[4] = "Juicy";
56+
}
57+
58+
public int getVolume() {
59+
return volume;
60+
}
61+
62+
public HeadPhoneColor getHeadPhoneColor() {
63+
return headPhoneColor;
64+
}
65+
66+
public boolean isPoweredOn() {
67+
return isPoweredOn;
68+
}
69+
70+
public boolean isWireless() {
71+
return isWireless;
72+
}
73+
74+
public String[] getBrandsArray() {
75+
return BrandUtils.PREFERRED_BRANDS;
76+
}
77+
78+
public void turnOn() {
79+
isPoweredOn = true;
80+
}
81+
82+
public void turnOff() {
83+
isPoweredOn = false;
84+
}
85+
86+
public void increaseVolume() {
87+
if (volume < 100) {
88+
volume++;
89+
}
90+
}
91+
92+
public void setVolume(int volume) {
93+
if (volume >= 0 && volume <= 100) {
94+
this.volume = volume;
95+
}
96+
}
97+
98+
public void decreaseVolume() {
99+
if (volume > 0) {
100+
volume--;
101+
}
102+
}
103+
104+
public void setColor(HeadPhoneColor color) {
105+
this.headPhoneColor = color;
106+
}
107+
108+
public class BrandUtils {
109+
private static final String[] PREFERRED_BRANDS = {
110+
"Beats", "Sony", "Bose", "SkullCandy", "Juicy"
111+
};
112+
113+
public static boolean isPreferredBrand(String brand) {
114+
return Arrays.asList(PREFERRED_BRANDS).contains(brand);
115+
}
116+
}
117+
118+
public boolean connectToBluetooth() {
119+
if (isPoweredOn && isWireless) {
120+
isConnectedToBluetooth = true;
121+
}
122+
return isConnectedToBluetooth;
123+
}
124+
125+
public boolean isConnectedToBluetooth() {
126+
return connectToBluetooth();
127+
}
128+
129+
public void wirelessConnection() throws ConnectionNotFoundException {
130+
if (!isConnectedToBluetooth) {
131+
throw new ConnectionNotFoundException("Headphones Wireless Connection Not Found.");
132+
}
133+
}
134+
}

0 commit comments

Comments
 (0)