Skip to content

Commit e871365

Browse files
authored
feat: adds Olivia's custom makeup routine object (#544)
* feat:add oliviajames lesson 16 hw (incopmplete) * feat: add lesson16 custom class MakeupRoutine.java & test cases with exception handling
1 parent 01c16f8 commit e871365

File tree

3 files changed

+160
-0
lines changed

3 files changed

+160
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.codedifferently.lesson16.oliviajames;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
6+
public class MakeupRoutine {
7+
8+
public enum MakeupLook {
9+
DEWY,
10+
NATURAL,
11+
FULL_GLAM,
12+
SOFT_GLAM,
13+
}
14+
15+
// Member Variables
16+
private String name;
17+
private int time;
18+
private final boolean usesPrimer;
19+
private final MakeupLook lookType;
20+
List<String> vanityItems;
21+
22+
// Constructor
23+
public MakeupRoutine(String name, int time, boolean usesPrimer, MakeupLook lookType) {
24+
this.name = name;
25+
this.time = time;
26+
this.usesPrimer = true;
27+
this.lookType = lookType;
28+
}
29+
30+
// Getters/setters
31+
32+
public String getName() {
33+
return name;
34+
}
35+
36+
public void setName(String name) {
37+
this.name = name;
38+
}
39+
40+
public int getTime() {
41+
return time;
42+
}
43+
44+
public void setTime(int time) {
45+
this.time = time;
46+
}
47+
48+
public boolean getUsesPrimer() throws MissingPrimerException {
49+
if (!usesPrimer) {
50+
throw new MissingPrimerException("missing primer");
51+
}
52+
System.out.println("has primer");
53+
return true;
54+
}
55+
56+
public MakeupLook getLookType() {
57+
return lookType;
58+
}
59+
60+
public void MakeupVanity() {
61+
vanityItems = new ArrayList<>();
62+
vanityItems.add("Foundation");
63+
vanityItems.add("Concealer");
64+
vanityItems.add("Setting Powder");
65+
vanityItems.add("Blush");
66+
vanityItems.add("Highlighter");
67+
vanityItems.add("Eyeshadow Palette");
68+
vanityItems.add("Mascara");
69+
vanityItems.add("Eyeliner");
70+
vanityItems.add("Lipstick");
71+
vanityItems.add("Lip Gloss");
72+
vanityItems.add("Setting Spray");
73+
vanityItems.add("Makeup Brushes");
74+
}
75+
76+
public void showVanityItems() {
77+
System.out.println("Items on the vanity:");
78+
for (String item : vanityItems) {
79+
System.out.println("- " + item);
80+
}
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.codedifferently.lesson16.oliviajames;
2+
3+
public class MissingPrimerException extends Exception {
4+
public MissingPrimerException(String message) {
5+
super(message);
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.codedifferently.lesson16.oliviajames;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
9+
import com.codedifferently.lesson16.oliviajames.MakeupRoutine.MakeupLook;
10+
import org.junit.jupiter.api.BeforeEach;
11+
import org.junit.jupiter.api.Test;
12+
13+
public class MakeupRoutineTest {
14+
15+
MakeupRoutine makeupRoutine;
16+
17+
@BeforeEach
18+
void setUp() {
19+
makeupRoutine = new MakeupRoutine("NARS", 60, true, MakeupLook.FULL_GLAM);
20+
}
21+
22+
@Test
23+
void testgetName() {
24+
String actual = makeupRoutine.getName();
25+
26+
assertThat(actual).isEqualTo("NARS");
27+
}
28+
29+
@Test
30+
public void testSetName() {
31+
makeupRoutine.setName("Night Out");
32+
assertEquals("Night Out", makeupRoutine.getName());
33+
}
34+
35+
@Test
36+
public void testGetTime() {
37+
assertEquals(60, makeupRoutine.getTime());
38+
}
39+
40+
@Test
41+
public void testSetTime() {
42+
makeupRoutine.setTime(45);
43+
assertEquals(45, makeupRoutine.getTime());
44+
}
45+
46+
@Test
47+
public void testGetLookType() {
48+
assertEquals(MakeupRoutine.MakeupLook.FULL_GLAM, makeupRoutine.getLookType());
49+
}
50+
51+
@Test
52+
public void testGetUsesPrimer() {
53+
try {
54+
makeupRoutine.getUsesPrimer();
55+
} catch (MissingPrimerException e) {
56+
System.out.println(e.getMessage());
57+
}
58+
}
59+
60+
@Test
61+
public void testShowVanityItems() {
62+
assertNotNull(makeupRoutine); // just to check vanityItems were initialized
63+
}
64+
65+
@Test
66+
public void testMakeupVanityHasItems() {
67+
makeupRoutine.MakeupVanity();
68+
assertFalse(makeupRoutine.vanityItems.isEmpty());
69+
assertTrue(makeupRoutine.vanityItems.contains("Foundation"));
70+
}
71+
}

0 commit comments

Comments
 (0)