Skip to content

Commit 6e4fabe

Browse files
committed
fix: Coins file added
1 parent 14e176a commit 6e4fabe

File tree

4 files changed

+134
-48
lines changed

4 files changed

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

lesson_16/objects/objects_app/src/main/java/com/codedifferently/lesson16/coinsc.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

lesson_16/objects/objects_app/src/test/java/com/codedifferently/lesson16/CoinsTest.Java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
package com.codedifferently.lesson16;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4-
import static org.junit.jupiter.api.Assertions.assertTrue;
5-
import static org.assertj.core.api.Assertions.assertThat;
64

7-
import org.junit.jupiter.api.Test;
5+
import java.sql.Array;
86
import java.util.ArrayList;
9-
import java.util.List;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
import com.codedifferently.lesson16.Coins.CoinType;
1011

1112
class CoinTest{
1213

14+
15+
1316
@Test
1417
void testCheckCoinInPocket(){
1518
//arrange
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package com.codedifferently.lesson16;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import java.sql.Array;
6+
import java.util.ArrayList;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
import com.codedifferently.lesson16.Coins.CoinType;
11+
12+
class CoinTest{
13+
14+
15+
16+
@Test
17+
void testCheckCoinInPocket(){
18+
//arrange
19+
Coins coin = new Coin(Coins.CoinType.NICKEL, 5, false, 5.0, 1966, new ArrayList<>(nickel,copper));
20+
//act action
21+
CoinType actualCoin = CoinType.NICKEL;
22+
23+
//assert
24+
assertEquals(CoinType.NICKEL,coins.checkCoinType())
25+
}
26+
@Test
27+
void testWeighCoins(){
28+
//arrange
29+
Coins coin = new Coin(Coins.CoinType.NICKEL, 5, false, 5.0, 1966, new ArrayList<>(nickel,copper));
30+
double expectedWeight = 5.0;
31+
//act
32+
double coinWeight = coin.coinGramWeight();
33+
//assert
34+
assertEquals(expected, coinWeight);
35+
}
36+
@Test
37+
void testConvertCoins(){
38+
//arrange
39+
coinCollection = new Arraylist<>();
40+
Coin nickel1 = new Coin();
41+
Coin nickel2 = new coin();
42+
coinCollection.add(nickel1);
43+
coinCollection.add(nickel2);
44+
45+
//act
46+
Coin Dime = Coin.convertNickelsToDime(nickel1, nickel2);
47+
//assert
48+
Assert(10, Dime.getValue())
49+
}
50+
@Test
51+
void testCollectCoins(){
52+
//arrange
53+
coinCollection = new Arraylist<>();
54+
Coin penny = new Coin();
55+
Coin nickel = new Coin();
56+
Coin dime = new Coin ();
57+
//act
58+
AddCoin(penny);
59+
AddCoin(nickel);
60+
AddCoin(dime);
61+
//assert
62+
AssertEquals(3,coinCollection());
63+
}
64+
@Test
65+
void testGetAgeCoin(){
66+
//arrange
67+
Coin coin = new Coin();
68+
// Act
69+
int age = coin.geCoinAge();
70+
// Assert
71+
assertEquals(1954, age);
72+
}
73+
@Test
74+
void testGetMaterialComposition(){
75+
Coin Penny = new Coin(new Arraylist<>(Array.asList("copper,zinc")))
76+
77+
}
78+
}

0 commit comments

Comments
 (0)