Skip to content

Commit 351dbe1

Browse files
committed
chore: fix formatting issues in Cat.java and CatTest.java
1 parent 6076094 commit 351dbe1

File tree

2 files changed

+106
-106
lines changed
  • lesson_16/objects/objects_app/src
    • main/java/com/codedifferently/lesson16/cutecat
    • test/java/com/codedifferently/lesson16/cutecat

2 files changed

+106
-106
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/cutecat/Cat.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ public class Cat {
3232

3333
// Constructor
3434
public Cat(String name, int age, double weight, Breed breed, boolean isIndoor, boolean isFemale)
35-
throws InvalidCatNameException {
36-
if (name == null || name.trim().isEmpty()) {
37-
throw new InvalidCatNameException("Cat name cannot be empty.");
38-
}
39-
this.name = name;
40-
this.age = age;
41-
this.weight = weight;
42-
this.isIndoor = isIndoor;
43-
this.breed = breed;
44-
this.isFemale = isFemale;
35+
throws InvalidCatNameException {
36+
if (name == null || name.trim().isEmpty()) {
37+
throw new InvalidCatNameException("Cat name cannot be empty.");
38+
}
39+
this.name = name;
40+
this.age = age;
41+
this.weight = weight;
42+
this.isIndoor = isIndoor;
43+
this.breed = breed;
44+
this.isFemale = isFemale;
4545
this.favoriteFoods =
4646
new ArrayList<>(Arrays.asList("Fancy Feast", "Purina Naturals")); // Default for Ninja
4747
}
Lines changed: 96 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,103 @@
11
package com.codedifferently.lesson16.cutecat;
22

3-
import org.junit.jupiter.api.Test;
43
import static org.junit.jupiter.api.Assertions.*;
4+
55
import java.util.ArrayList;
6+
import org.junit.jupiter.api.Test;
67

78
public class CatTest {
89

9-
@Test
10-
public void testCreateNinjaCat() throws InvalidCatNameException {
11-
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
12-
assertEquals("Ninja", cat.getName());
13-
assertEquals(13, cat.getAge());
14-
assertEquals(9.3, cat.getWeight());
15-
assertTrue(cat.getIsIndoor());
16-
assertEquals(Breed.MAINCOON, cat.getBreed());
17-
}
18-
19-
@Test
20-
public void testfavoriteFoodsDefault() throws InvalidCatNameException {
21-
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
22-
ArrayList<String> foods = cat.getfavoriteFoods();
23-
assertTrue(foods.contains("Fancy Feast"));
24-
assertTrue(foods.contains("Purina Naturals"));
25-
assertEquals(2, foods.size());
26-
}
27-
28-
@Test
29-
public void testPrintFavoriteFoodsCoverage() throws InvalidCatNameException {
30-
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
31-
cat.printfavoriteFoods();
32-
}
33-
34-
@Test
35-
public void testAddFavoriteFood() throws InvalidCatNameException {
36-
Cat cat = new Cat("Ninja", 13,9.3, Breed.MAINCOON, true, false);
37-
cat.addfavoriteFood("Tuna");
38-
ArrayList<String> foods = cat.getfavoriteFoods();
39-
assertTrue(foods.contains("Tuna"));
40-
assertEquals(3, foods.size());
41-
}
42-
43-
@Test
44-
public void testIsSenior() throws InvalidCatNameException {
45-
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
46-
assertTrue(cat.isSenior());
47-
}
48-
49-
@Test
50-
public void testCatName() throws InvalidCatNameException {
51-
Cat cat = new Cat("Whiskers",5, 5.4, Breed.SPHYNX, false, true);
52-
assertEquals("Whiskers", cat.getName());
53-
}
54-
55-
@Test
56-
public void testCatMeow() throws InvalidCatNameException {
57-
Cat cat = new Cat("Mittens", 2, 8.9, Breed.SIAMESE, true, true);
58-
assertEquals("Meow!", cat.meow());
59-
}
60-
61-
@Test
62-
public void testGetName() throws InvalidCatNameException {
63-
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, true);
64-
assertEquals("Shadow", cat.getName());
65-
}
66-
67-
@Test
68-
public void testGetAge() throws InvalidCatNameException {
69-
Cat cat = new Cat("Nine", 2, 13.2, Breed.MAINCOON, true, false);
70-
assertEquals(2, cat.getAge());
71-
}
72-
73-
@Test
74-
public void testMeow()throws InvalidCatNameException {
75-
Cat cat = new Cat("Frisky", 2, 5.4, Breed.UNKNOWN, true, true);
76-
assertEquals("Meow!", cat.meow());
77-
}
78-
79-
@Test
80-
public void testWalk() throws InvalidCatNameException {
81-
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, false);
82-
assertEquals("Shadow is walking.", cat.walk());
83-
}
84-
85-
@Test
86-
public void testSleep() throws InvalidCatNameException {
87-
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, false);
88-
assertEquals("Shadow is sleeping.", cat.sleep());
89-
}
90-
91-
@Test
92-
public void testisKittenTrue() throws InvalidCatNameException {
93-
Cat cat = new Cat("Tiny", 0, 2.5, Breed.PERSIAN, true, true);
94-
assertTrue(cat.isKitten());
95-
}
96-
97-
@Test
98-
public void testIsKittenFalse() throws InvalidCatNameException {
99-
Cat cat = new Cat("Trinity", 3, 5.6, Breed.UNKNOWN, true, true);
100-
assertFalse(cat.isKitten());
101-
}
102-
103-
}
10+
@Test
11+
public void testCreateNinjaCat() throws InvalidCatNameException {
12+
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
13+
assertEquals("Ninja", cat.getName());
14+
assertEquals(13, cat.getAge());
15+
assertEquals(9.3, cat.getWeight());
16+
assertTrue(cat.getIsIndoor());
17+
assertEquals(Breed.MAINCOON, cat.getBreed());
18+
}
19+
20+
@Test
21+
public void testfavoriteFoodsDefault() throws InvalidCatNameException {
22+
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
23+
ArrayList<String> foods = cat.getfavoriteFoods();
24+
assertTrue(foods.contains("Fancy Feast"));
25+
assertTrue(foods.contains("Purina Naturals"));
26+
assertEquals(2, foods.size());
27+
}
28+
29+
@Test
30+
public void testPrintFavoriteFoodsCoverage() throws InvalidCatNameException {
31+
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
32+
cat.printfavoriteFoods();
33+
}
34+
35+
@Test
36+
public void testAddFavoriteFood() throws InvalidCatNameException {
37+
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
38+
cat.addfavoriteFood("Tuna");
39+
ArrayList<String> foods = cat.getfavoriteFoods();
40+
assertTrue(foods.contains("Tuna"));
41+
assertEquals(3, foods.size());
42+
}
43+
44+
@Test
45+
public void testIsSenior() throws InvalidCatNameException {
46+
Cat cat = new Cat("Ninja", 13, 9.3, Breed.MAINCOON, true, false);
47+
assertTrue(cat.isSenior());
48+
}
49+
50+
@Test
51+
public void testCatName() throws InvalidCatNameException {
52+
Cat cat = new Cat("Whiskers", 5, 5.4, Breed.SPHYNX, false, true);
53+
assertEquals("Whiskers", cat.getName());
54+
}
55+
56+
@Test
57+
public void testCatMeow() throws InvalidCatNameException {
58+
Cat cat = new Cat("Mittens", 2, 8.9, Breed.SIAMESE, true, true);
59+
assertEquals("Meow!", cat.meow());
60+
}
61+
62+
@Test
63+
public void testGetName() throws InvalidCatNameException {
64+
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, true);
65+
assertEquals("Shadow", cat.getName());
66+
}
67+
68+
@Test
69+
public void testGetAge() throws InvalidCatNameException {
70+
Cat cat = new Cat("Nine", 2, 13.2, Breed.MAINCOON, true, false);
71+
assertEquals(2, cat.getAge());
72+
}
73+
74+
@Test
75+
public void testMeow() throws InvalidCatNameException {
76+
Cat cat = new Cat("Frisky", 2, 5.4, Breed.UNKNOWN, true, true);
77+
assertEquals("Meow!", cat.meow());
78+
}
79+
80+
@Test
81+
public void testWalk() throws InvalidCatNameException {
82+
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, false);
83+
assertEquals("Shadow is walking.", cat.walk());
84+
}
85+
86+
@Test
87+
public void testSleep() throws InvalidCatNameException {
88+
Cat cat = new Cat("Shadow", 2, 7.4, Breed.BENGAL, true, false);
89+
assertEquals("Shadow is sleeping.", cat.sleep());
90+
}
91+
92+
@Test
93+
public void testisKittenTrue() throws InvalidCatNameException {
94+
Cat cat = new Cat("Tiny", 0, 2.5, Breed.PERSIAN, true, true);
95+
assertTrue(cat.isKitten());
96+
}
97+
98+
@Test
99+
public void testIsKittenFalse() throws InvalidCatNameException {
100+
Cat cat = new Cat("Trinity", 3, 5.6, Breed.UNKNOWN, true, true);
101+
assertFalse(cat.isKitten());
102+
}
103+
}

0 commit comments

Comments
 (0)