Skip to content
Snippets Groups Projects
Commit 2a3f5f4e authored by raphael.rampf's avatar raphael.rampf
Browse files

last push part 3

parent 9a6d3933
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 79 deletions
......@@ -47,7 +47,7 @@ Flowchart I coded :
## part 3
- unit test done for class dealer
- unit test done for class dealer and BlackJackHand
- Quentin said one class with unit test was enough;
- ai for cpu is done
- they make the correct choice
......
......@@ -127,7 +127,7 @@ public class App extends Application {
if (numberOfCpu != 0) {
gameManager = new GameManager(Integer.parseInt(moneyPlayer.getText()), 6, 52);
gameManager.addCpu(numberOfCpu, dumb);
// gameManager.shuffleDeck();
gameManager.shuffleDeck();
stage.setScene(sceneInGame);
//maj argent value for next scene
argentValue.setText(String.valueOf(gameManager.human.getMoney()));
......
package org.openjfx;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.util.ArrayList;
import org.junit.Test;
public class BlackJackHandTest {
@Test
public void ConstructorTest() {
BlackJackHand hand = new BlackJackHand();
// a hand is returned
assertNotNull("returned BlackJackHand is NULL", hand);
// returned object is a dealer
assertEquals("didn't return a BlackJackHand", BlackJackHand.class, hand.getClass());
//bet = 0
assertEquals("bet is not 0", 0, hand.getBet());
//stayed = false
assertFalse("stayed is not false", hand.getStayed());
//acesplited = false
assertFalse("aceSplited is not false", hand.getAceSplited());
}
@Test
public void getBetTest(){
BlackJackHand hand = new BlackJackHand();
hand.addBet(5);
int bet = hand.getBet();
//returns 5
assertEquals("didn't return the good value", 5, bet);
}
@Test
public void addBetTest(){
BlackJackHand hand = new BlackJackHand();
hand.addBet(5);
int bet = hand.getBet();
//returns 5
assertEquals("didn't return the good value", 5, bet);
}
@Test
public void getCardsTest(){
BlackJackHand hand = new BlackJackHand();
Card card = new Card(COLOR.carreau, 5);
hand.cards.add(card);
ArrayList<Card> array = hand.getCards();
//returns an arraylist
assertEquals("didnt return Arraylist", ArrayList.class, array.getClass());
}
@Test
public void scoreTest(){
BlackJackHand hand = new BlackJackHand();
Card card = new Card(COLOR.carreau, 5);
Card card2 = new Card(COLOR.carreau, 5);
hand.cards.add(card);
hand.cards.add(card2);
int score = hand.score();
//return 10
assertEquals("didn't return the good value", 10, score);
hand = new BlackJackHand();
card = new Card(COLOR.carreau, 1);
card2 = new Card(COLOR.carreau, 5);
hand.cards.add(card);
hand.cards.add(card2);
score = hand.score();
//return 16
assertEquals("didn't return the good value", 16, score);
hand = new BlackJackHand();
card = new Card(COLOR.carreau, 1);
card2 = new Card(COLOR.carreau, 1);
hand.cards.add(card);
hand.cards.add(card2);
score = hand.score();
//return 12
assertEquals("didn't return the good value", 12, score);
hand = new BlackJackHand();
card = new Card(COLOR.carreau, 1);
card2 = new Card(COLOR.carreau, 11);
hand.cards.add(card);
hand.cards.add(card2);
score = hand.score();
//return 999
assertEquals("didn't return the good value", 999, score);
}
}
No preview for this file type
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
File deleted
artifactId=sample
groupId=org.openjfx
version=1.0.0
org/openjfx/DealetTest.class
/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/test/java/org/openjfx/DealetTest.java
File deleted
<?xml version="1.0" encoding="UTF-8"?>
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="org.openjfx.DealetTest" time="0.03" tests="7" errors="0" skipped="0" failures="0">
<properties>
<property name="java.specification.version" value="21"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.class.path" value="/home/rampfun/hepia/2eme/1_poo/project_object/part_3/target/test-classes:/home/rampfun/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/rampfun/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-controls/21.0.2/javafx-controls-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-graphics/21.0.2/javafx-graphics-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-base/21.0.2/javafx-base-21.0.2.jar:"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.vendor.url" value="https://java.oracle.com/"/>
<property name="os.name" value="Linux"/>
<property name="java.vm.specification.version" value="21"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="user.country" value="US"/>
<property name="sun.boot.library.path" value="/usr/local/jdk-21/lib"/>
<property name="sun.java.command" value="org.apache.maven.surefire.booter.ForkedBooter /home/rampfun/hepia/2eme/1_poo/project_object/part_3/target/surefire 2024-02-02T22-01-22_553-jvmRun1 surefire12859069346639590549tmp surefire_0933894748556831800tmp"/>
<property name="jdk.debug" value="release"/>
<property name="surefire.test.class.path" value="/home/rampfun/hepia/2eme/1_poo/project_object/part_3/target/test-classes:/home/rampfun/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/rampfun/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-controls/21.0.2/javafx-controls-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-graphics/21.0.2/javafx-graphics-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-base/21.0.2/javafx-base-21.0.2.jar:"/>
<property name="sun.cpu.endian" value="little"/>
<property name="user.home" value="/home/rampfun"/>
<property name="user.language" value="en"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="jdk.module.path" value="/home/rampfun/hepia/2eme/1_poo/project_object/part_3/target/classes:/home/rampfun/.m2/repository/org/openjfx/javafx-controls/21.0.2/javafx-controls-21.0.2-linux.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-graphics/21.0.2/javafx-graphics-21.0.2-linux.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-base/21.0.2/javafx-base-21.0.2-linux.jar"/>
<property name="java.version.date" value="2023-09-19"/>
<property name="java.home" value="/usr/local/jdk-21"/>
<property name="file.separator" value="/"/>
<property name="basedir" value="/home/rampfun/hepia/2eme/1_poo/project_object/part_3"/>
<property name="java.vm.compressedOopsMode" value="Zero based"/>
<property name="line.separator" value="&#10;"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="surefire.real.class.path" value="/home/rampfun/.m2/repository/org/apache/maven/surefire/surefire-booter/2.22.1/surefire-booter-2.22.1.jar:/home/rampfun/.m2/repository/org/apache/maven/surefire/surefire-api/2.22.1/surefire-api-2.22.1.jar:/home/rampfun/.m2/repository/org/apache/maven/surefire/surefire-logger-api/2.22.1/surefire-logger-api-2.22.1.jar:/home/rampfun/hepia/2eme/1_poo/project_object/part_3/target/test-classes:/home/rampfun/.m2/repository/junit/junit/4.11/junit-4.11.jar:/home/rampfun/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-controls/21.0.2/javafx-controls-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-graphics/21.0.2/javafx-graphics-21.0.2.jar:/home/rampfun/.m2/repository/org/openjfx/javafx-base/21.0.2/javafx-base-21.0.2.jar:/home/rampfun/.m2/repository/org/apache/maven/surefire/surefire-junit4/2.22.1/surefire-junit4-2.22.1.jar"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="java.runtime.version" value="21+35-2513"/>
<property name="user.name" value="rampfun"/>
<property name="stdout.encoding" value="UTF-8"/>
<property name="path.separator" value=":"/>
<property name="os.version" value="6.5.0-15-generic"/>
<property name="java.runtime.name" value="OpenJDK Runtime Environment"/>
<property name="file.encoding" value="UTF-8"/>
<property name="java.vm.name" value="OpenJDK 64-Bit Server VM"/>
<property name="localRepository" value="/home/rampfun/.m2/repository"/>
<property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/>
<property name="java.io.tmpdir" value="/tmp"/>
<property name="java.version" value="21"/>
<property name="user.dir" value="/home/rampfun/hepia/2eme/1_poo/project_object/part_3"/>
<property name="os.arch" value="amd64"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="native.encoding" value="UTF-8"/>
<property name="java.library.path" value="/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="stderr.encoding" value="UTF-8"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="java.vm.version" value="21+35-2513"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="java.class.version" value="65.0"/>
</properties>
<testcase name="drawTest" classname="org.openjfx.DealetTest" time="0.005"/>
<testcase name="getFirstCardTest" classname="org.openjfx.DealetTest" time="0"/>
<testcase name="ConstructorTest" classname="org.openjfx.DealetTest" time="0"/>
<testcase name="compareHandTest" classname="org.openjfx.DealetTest" time="0"/>
<testcase name="resetTest" classname="org.openjfx.DealetTest" time="0"/>
<testcase name="getHandTest" classname="org.openjfx.DealetTest" time="0"/>
<testcase name="scoreTest" classname="org.openjfx.DealetTest" time="0"/>
</testsuite>
\ No newline at end of file
-------------------------------------------------------------------------------
Test set: org.openjfx.DealetTest
-------------------------------------------------------------------------------
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 s - in org.openjfx.DealetTest
--patch-module
org.openjfx=_
--add-reads
org.openjfx=ALL-UNNAMED
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment