Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Here is my question. -how would i create an array of 5 cards -In a for loop, cre

ID: 3644549 • Letter: H

Question

Here is my question.

-how would i create an array of 5 cards

-In a for loop, create each card and add it to the array. While passing in random numbers between 1 and 3 for each of the parameters to the constructor

-then, loop through and toString() on each card.
------------------------------------------------------------------------------------
-here is the background code.

public class Card
{
// Creating parameters for the gamee
private String colorOfObj;
private String shapeKind ;
private String shadeType ;
private int number ;

/* Creating a default constructor, which tells
* the program to create this.
*/
public Card()
{
colorOfObj = "Red";
shapeKind = "squiggle";
shadeType = "solid";
number = 1;
}//default

/* A parameterized constructor that takes inputs
* and set parameters equal to them
*/
public Card(String color , String shape, String shade, int num)
{
colorOfObj = color;
shapeKind = shape;
shadeType = shade;
number = num ;
}//parameterized constructor

/* Now we need to set some retrieving methods, since the
* parameters are private. It means that it can not be access from
* from outside, but say when we are doing a certian class we want to know
* color of the object. These are the methods that will give it to you.
*/

// Setting up the method color
public void setColor(String color)
{
colorOfObj = color;
}

// Set shape
public void setShape(String shape)
{
shapeKind = shape;
}
// Set shade
public void setShade(String shade)
{
shadeType = shade;
}
// Set number
public void setNumber(int num)
{
number = num;
}


/* A method that returns an integer or string, 'return int'
* will give you and integer
*/

// Get color
public String getColor()
{
return colorOfObj;
}
// Get shape
public String getShape()
{
return shapeKind;
}
// Get shade
public String getShade()
{
return shadeType;
}
// Get number
public int getNumber()
{
return number;
}

//Return a string representation of a card
public String toString()
{
return number + "," + shadeType + "," + colorOfObj + "," + shapeKind;
}

private String getColorString(int num)
{
switch(num)
{
case 1: return "Red";
case 2: return "Purple";
case 3: return "green";

default: return "invalid";

}

}

private String getShapeString(int num)
{
switch(num)
{
case 1: return "Squiggle";
case 2: return "Diamond";
case 3: return "Oval";

default: return "invalid";
}
}

private String getShadeString(int num)
{
switch(num)
{
case 1: return "Solid";
case 2: return "Shaded";
case 3: return "open";

default: return "invalid";
}
}
}//class card

----------------------------------------------------------------------------------------------------
now here what i started with in my driver for the game

the main.

/*
* File: SetGame.java
* ---------------------
* This program will resemble the the game SET GAME.
* SETGAME will be the driver for the game
*/


import acm.program.ConsoleProgram;
import acm.util.*;

public class SetGame extends ConsoleProgram
{
RandomGenerator rg = new RandomGenerator();

public void run()
{
String[] cards;
cards = new String[5];
for (int i = 0; i < cards.length ; i++)
{


println(cards[i]);
}
}//run
}//class

Explanation / Answer

well dear i think this is ur solution package javapoker; 02 03 public class Hand { 04 private Card[] cards; 05 private int[] value; 06 07 Hand(Deck d) 08 { 09 value = new int[6]; 10 cards = new Card[5]; 11 for (int x=0; x
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote