Computer Science hand.java package poker; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import poker.Card; public class Hand { //private transient int i=10; // marked transient they will not serialized / deserialized public Card[] cards;

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
 

Computer Science

hand.java
package poker;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import poker.Card;

public class Hand
{
//private transient int i=10;
// marked transient they will not serialized / deserialized

public Card[] cards;

public Hand()
{
}

public boolean is_better_than(Hand H)
{
return false;
}
  
public boolean is_equal(Hand H)
{
return false;
}
}

card.java
package poker;

public class Card
{
public enum Suite
{
HEARTS,CLUBS,DIAMONDS,SPADES
}

public enum Value
{
ACE,TWO,THREE,FOUR,FIVE,SIX,SEVEN,EIGHT,NINE,
TEN,JACK,QUEEN,KING
}

public Suite suite;
public Value value;

public Card()
{

}
}

 

// main.java


import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import poker.Hand;
import poker.Card;


public class Main
{

public static void main(String[] args)
{
// this function is provided as a convenient way to
// run the code from the command line.
//
// it will not be graded, but it needs to compile and
// execute without a failure.

System.out.println("Start");

// Demonstrate converting json in and out of a 'Hand'
//
Hand H1 = new Hand();

// allocate space for 5 card references
H1.cards = new Card[5];
H1.cards[0] = new Card();
H1.cards[0].suite = Card.Suite.valueOf("SPADES");
H1.cards[0].value = Card.Value.valueOf("FIVE");
H1.cards[1] = new Card();
H1.cards[1].suite = Card.Suite.valueOf("SPADES");
H1.cards[1].value = Card.Value.valueOf("FOUR");
H1.cards[2] = new Card();
H1.cards[2].suite = Card.Suite.valueOf("SPADES");
H1.cards[2].value = Card.Value.valueOf("THREE");
H1.cards[3] = new Card();
H1.cards[3].suite = Card.Suite.valueOf("SPADES");
H1.cards[3].value = Card.Value.valueOf("TWO");
H1.cards[4] = new Card();
H1.cards[4].suite = Card.Suite.valueOf("SPADES");
H1.cards[4].value = Card.Value.valueOf("ACE");

// turn it into json
Gson gson = new Gson();
String jsonString = gson.toJson(H1);
System.out.println(jsonString);

// and back into a "hand"
Hand H3 = new Hand();
H3 = gson.fromJson(jsonString,Hand.class);

// change something
H3.cards[4].suite = Card.Suite.valueOf("DIAMONDS");
H3.cards[4].value = Card.Value.valueOf("FIVE");

// show that it works
System.out.println(gson.toJson(H3));

// show the comparison function
Hand H2 = new Hand();
H2 = H1;


if (H1.is_better_than(H2))
{
System.out.println("hand1 is better than hand2");
}

if (H2.is_better_than(H1))
{
System.out.println("hand2 is better than hand1");
}
System.out.println("End");

}
}

 

 

 

Instructions for your tutor:

Mechanize the ranking of poker hands of 5 cards. This will require you to implement the "is_better_than ()" method. You may create other methods if desired

and arrange 15 tests

Send

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY