Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have java coding questions and need help passing them through the test cases below, this is quite urgent!! currently none of the codes are

I have java coding questions and need help passing them through the test cases below, this is quite urgent!! currently none of the codes are running and passing the tests. Please don't add any new classes.
*These are the test cases below*
package tests.stage1;
@SuppressWarnings("unused")
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class CardTest {
public static Rank rank1, rank2, rank3, rank4;
public static Suit suit1, suit2, suit3, suit4;
public static Card card1, card2, card3, card4;
@BeforeAll
public static void init(){
rank1= new Rank("Ace",'A',14);
suit1= new Suit("Hearts",'H', "red", 1);
card1= new Card(rank1, suit1);
rank2= new Rank("Jack",'J',11);
suit2= new Suit("Diamonds",'D', "red", 2);
card2= new Card(rank2, suit2);
rank3= new Rank("Ten",'X',10);
suit3= new Suit("Clubs",'C', "black", 3);
card3= new Card(rank3, suit3);
rank4= new Rank("Five",'5',5);
suit4= new Suit("Spades",'S', "black", 4);
card4= new Card(rank4, suit4);;
}
@Test
@Graded(description = "Card constructor", marks =10)
@Order(1)
public void testCardConstructor(){
//Card objects already constructed in init(). Check them out
assertEquals("Ace", card1.rank.name);
assertEquals("Hearts", card1.suit.name);
assertEquals("Jack", card2.rank.name);
assertEquals("Diamonds", card2.suit.name);
assertEquals("Ten", card3.rank.name);
assertEquals("Clubs", card3.suit.name);
assertEquals("Five", card4.rank.name);
assertEquals("Spades", card4.suit.name);
currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();
}
@Test
@Graded(description = "Card value", marks =10)
@Order(2)
public void testCardValue(){
assertEquals(141, card1.value());
assertEquals(112, card2.value());
assertEquals(103, card3.value());
assertEquals(54, card4.value());
currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();
}
Here is the code to fix and ensure they pass the above tests on JavaScript, please do not create any private classes or enums, do not override anything either AND I am not allowed to add new public classes. Please provide a solutions!!
*The java codes that need to be solved are below*
package toBeCompleted.stage1;
public class Card {
public Suit suit;
public Rank rank;
/**
* Constructor for Card
*
* @param rank
* @param suit
*/
public Card(Rank rank, Suit suit){
this.rank = new Rank(rank.name, rank.symbol, rank.value);
this.suit = new Suit(suit.name, suit.symbol, suit.color, suit.value);
}
/**
* Returns the string representation of the card as a combination of rank and
* suit.
* See test cases for examples.
*/
public String toString(){
return "";
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions