Skip to content

Commit 14e176a

Browse files
committed
fix: more bugs
1 parent f88bf24 commit 14e176a

File tree

3 files changed

+87
-61
lines changed

3 files changed

+87
-61
lines changed

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/Coins.Java

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.codedifferently.lesson16;
2+
3+
public class Coins {
4+
5+
public enum CoinType{
6+
PENNY, NICKEL, DIME, QUARTER
7+
}
8+
private CoinType coinType;
9+
private int coinValue;
10+
private boolean coinIsRare;
11+
private double coinGramWeight;
12+
private int coinAge;
13+
private Arraylist<String> material;
14+
15+
//constructor
16+
public Coins(CoinType coinType, int coinValue, Boolean coinIsRare, Double coinGramWeight, Arraylist material) {
17+
this.coinType = coinType;
18+
this.coinValue = coinValue;
19+
this.coinIsRare = coinIsRare;
20+
this.coinGramWeight = coinGramWeight;
21+
this.coinAge = coinAge;
22+
this.material = material;
23+
}
24+
//Getters and Setters
25+
public CoinType getCoinType(){
26+
return coinType;
27+
}
28+
public int getCoinValue(){
29+
return coinValue;
30+
}
31+
public boolean isCoinRare(){
32+
return coinIsRare;
33+
}
34+
public double getCoinGramWeight(){
35+
return coinGramWeight;
36+
}
37+
public int getCoinAge() {
38+
return coinAge;
39+
}
40+
public List<String> getMaterial(){
41+
return material;}
42+
}
43+
//todo
44+
// for loop for coin collection and check if rare add to collection
Lines changed: 43 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,75 @@
11
package com.codedifferently.lesson16;
22

3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
35
import static org.assertj.core.api.Assertions.assertThat;
46

57
import org.junit.jupiter.api.Test;
8+
import java.util.ArrayList;
9+
import java.util.List;
610

711
class CoinTest{
812

9-
@test
10-
void testCheckCoininPocket(){
13+
@Test
14+
void testCheckCoinInPocket(){
1115
//arrange
12-
Coins coin = new Coin(to fill in);
13-
16+
Coins coin = new Coin(Coins.CoinType.NICKEL, 5, false, 5.0, 1966, new ArrayList<>(nickel,copper));
1417
//act action
15-
CoinType actualCoin = CoinType.nickel;
18+
CoinType actualCoin = CoinType.NICKEL;
1619

1720
//assert
18-
assertEquals(nickel,coins.checkCoinType())
21+
assertEquals(CoinType.NICKEL,coins.checkCoinType())
1922
}
20-
@test
21-
void testWeighCoins(){
23+
@Test
24+
void testWeighCoins(){
2225
//arrange
23-
Coins coin = new Coin(to fill in);
24-
double expectedWeight = 5.0;
26+
Coins coin = new Coin(Coins.CoinType.NICKEL, 5, false, 5.0, 1966, new ArrayList<>(nickel,copper));
27+
double expectedWeight = 5.0;
2528
//act
26-
double coinWeight = coin.coinGramWeight();
29+
double coinWeight = coin.coinGramWeight();
2730
//assert
28-
assertEquals(expected, coinweight);
31+
assertEquals(expected, coinWeight);
2932
}
30-
@test
31-
void testConvertCoins(){
33+
@Test
34+
void testConvertCoins(){
3235
//arrange
33-
coinCollection = new Arraylist<>();
34-
Coin nickel1 = new coin();
35-
Coin nickel2 = new coin();
36-
coinCollection.add(nickel1);
37-
coinCollection.add(nickel2);
36+
coinCollection = new Arraylist<>();
37+
Coin nickel1 = new Coin();
38+
Coin nickel2 = new coin();
39+
coinCollection.add(nickel1);
40+
coinCollection.add(nickel2);
3841

3942
//act
40-
Coin Dime = Coin.convertNickelsToDime();
43+
Coin Dime = Coin.convertNickelsToDime(nickel1, nickel2);
4144
//assert
42-
Assert(10, Dime.getValue())
45+
Assert(10, Dime.getValue())
4346
}
4447
@Test
45-
void testCollectCoins(){
48+
void testCollectCoins(){
4649
//arrange
47-
coinCollection = new Arraylist<>();
48-
Coin penny = new coin();
49-
Coin nickel = new coin();
50-
Coin dime = new coin ();
51-
add coins to coin collection
50+
coinCollection = new Arraylist<>();
51+
Coin penny = new Coin();
52+
Coin nickel = new Coin();
53+
Coin dime = new Coin ();
5254
//act
53-
AddCoin(penny);
54-
AddCoin(nickel);
55-
AddCoin(dime);
55+
AddCoin(penny);
56+
AddCoin(nickel);
57+
AddCoin(dime);
5658
//assert
57-
AssertEquals(3,coinCollection());
59+
AssertEquals(3,coinCollection());
5860
}
59-
@test
60-
void testGetAgeCoin(){
61+
@Test
62+
void testGetAgeCoin(){
6163
//arrange
62-
Coin coin = new coin();
64+
Coin coin = new Coin();
6365
// Act
6466
int age = coin.geCoinAge();
6567
// Assert
66-
assertEquals(1954, actual);
68+
assertEquals(1954, age);
6769
}
68-
}
70+
@Test
71+
void testGetMaterialComposition(){
72+
Coin Penny = new Coin(new Arraylist<>(Array.asList("copper,zinc")))
73+
74+
}
75+
}

0 commit comments

Comments
 (0)