Question: Convert this from Java to Ruby. //Define the method checkSet(). public static boolean checkSet (Card card one, Card card_two, Card card three) //Initialize the required
Convert this from Java to Ruby.
//Define the method checkSet().
public static boolean checkSet (Card card one, Card card_two, Card card three)
//Initialize the required variables.
boolean rank status = false;
boolean color status = false;
boolean shape status = false;
boolean fill status = false;
//If rank of each card is same, then set the //rank status true.
if (card_one.rank_Of Card == card two. rank_of_Card && card one.rank_Of_Card == card_three.rank of_Card)
rank status = true;
//If rank of each card is different, then set // the rank status true.
else if (card one.rank Of Card != card two. rank_Of_Card && card_two.rank_Of_Card != card_three.rank_Of Card && card one. rank_Of_Card != card three.rank_of_Card)
rank status = true;
//If fill of each card is same, then set //the fill status true.
if (card_one.fill_card == card two.fill_card && card one.fill card == card three. fill card)
fill status = true;
//If fill of each card is different, then set
// the fill status true.
else if (card one.fill card != card two. fill card && card two.fill card != card_three.fill_card && card one.fill_card != card three.fill card)
fill status = true;
//If shape of each card is same, then set
//the shape status true.
if (card one.card shape == card two. card_shape && card_one.card_shape == card_three.card shape)
shape_status = true;
//If shape of each card is different, then set
//the shape status true.
else if (card_one.card shape != card_two. card_shape && card two.card shape != card_three.card_shape && card one.card_shape != card three.card shape)
shape status = true;
//If color of each card is same, then set
// the color status true.
if (card_one.card_color == card_two. card_color && card one.card color == card_three.card color)
color status = true;
//If color of each card is different, then set
//the color status true.
else if (card one. card color != card two. card color && card two.card color != card three.card color && card one. card color != card three.card color)
color_status = true;
//Get the result of AND of each status.
boolean isCardSet = rank status && color status && fill status && shape status;
//Return the result.
return isCardSet;
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
