Skip to content

Commit f88bf24

Browse files
committed
feat:lesson_16 Coins and CoinTest files added
1 parent 2e32759 commit f88bf24

File tree

2 files changed

+93
-0
lines changed
  • lesson_16/objects/objects_app/src

2 files changed

+93
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.codedifferently.Coins;
2+
3+
//class
4+
public class Coins {
5+
6+
public enum CoinType{
7+
penny, nickel, dime, quarter
8+
}
9+
private int coinValue;
10+
private boolean coinIsRare;
11+
private double coinGramWeight;
12+
private int coinAge;
13+
private Arraylist<Coins> coincollection;
14+
15+
//constructor
16+
public Coins(CoinType coinType, int coinValue, Boolean coinIsRare, Double coinGramWeight) {
17+
this.coinType = coinType;
18+
this.coinValue = coinValue;
19+
this.coinIsRare = coinIsRare;
20+
this.coinGramWeight = coinGramWeight;
21+
this.coinAge = coinAge;
22+
this.coincollection = coinCollection;
23+
}
24+
}
25+
// for loop for coin collection and check if rare add to collection
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.codedifferently.lesson16;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class CoinTest{
8+
9+
@test
10+
void testCheckCoininPocket(){
11+
//arrange
12+
Coins coin = new Coin(to fill in);
13+
14+
//act action
15+
CoinType actualCoin = CoinType.nickel;
16+
17+
//assert
18+
assertEquals(nickel,coins.checkCoinType())
19+
}
20+
@test
21+
void testWeighCoins(){
22+
//arrange
23+
Coins coin = new Coin(to fill in);
24+
double expectedWeight = 5.0;
25+
//act
26+
double coinWeight = coin.coinGramWeight();
27+
//assert
28+
assertEquals(expected, coinweight);
29+
}
30+
@test
31+
void testConvertCoins(){
32+
//arrange
33+
coinCollection = new Arraylist<>();
34+
Coin nickel1 = new coin();
35+
Coin nickel2 = new coin();
36+
coinCollection.add(nickel1);
37+
coinCollection.add(nickel2);
38+
39+
//act
40+
Coin Dime = Coin.convertNickelsToDime();
41+
//assert
42+
Assert(10, Dime.getValue())
43+
}
44+
@Test
45+
void testCollectCoins(){
46+
//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
52+
//act
53+
AddCoin(penny);
54+
AddCoin(nickel);
55+
AddCoin(dime);
56+
//assert
57+
AssertEquals(3,coinCollection());
58+
}
59+
@test
60+
void testGetAgeCoin(){
61+
//arrange
62+
Coin coin = new coin();
63+
// Act
64+
int age = coin.geCoinAge();
65+
// Assert
66+
assertEquals(1954, actual);
67+
}
68+
}

0 commit comments

Comments
 (0)