Question: 1. the First function counts how many cards are hearts 2. Add the elements of two arrays of the same length. 3. Write a reverseArray

 1. the First function counts how many cards are hearts 2.1. the First function counts how many cards are hearts
2. Add the elements of two arrays of the same length.
3. Write a reverseArray method including method header and Javadoc comments
here is the card class

public class Card {

// min/max for the card number range

private static final int MIN_NUMBER = 1;

private static final int MAX_NUMBER = 13;

private int number;

private String suit;

private boolean faceUp = false; // whether the card is face up

public Card(int tempNumber, String tempSuit){

number = tempNumber;

suit = tempSuit.toLowerCase();

if( !isValidSuit(suit) ){

System.out.println(tempSuit + "Is not a valid suit!");

System.out.println("Must be one of: clubs, diamonds, hearts or spades");

System.out.println("Defaulting to hearts");

suit = "hearts";

}

if( !isValidNumber(number) ){

System.out.println(tempNumber + "Is not a valid number!");

System.out.println("Must be between " + MIN_NUMBER + " and " + MAX_NUMBER);

System.out.println("Defaulting to 1");

number = 1;

}

}

public String getSuit(){

return suit;

}

public String getNumber(){

if( number == 1 ){

return "Ace";

}else if( number >= 2 && number

return Integer.toString(number);

}else if( number == 11 ){

return "Jack";

}else if( number == 12 ){

return "Queen";

}else{

return "King";

}

}

public boolean isFaceUp(){

return faceUp;

}

public void flip(){

faceUp = !faceUp;

}

public String toString(){

return getNumber() + " of " + getSuit();

}

public void cheat(){

number = 1; // ACE!

}

private boolean isValidNumber(int num){

return num >= MIN_NUMBER && num MAX_NUMBER;

}

private boolean isValidSuit(String s){

return s.equals("spades") ||

s.equals("hearts") ||

s.equals("clubs") ||

s.equals("diamonds");

}

/**

* The value of this card for the flippy card game.

* Numbers have their number as the value, Ace is 11,

* and Jack, Queen, and King are 10.

*

* @return the flippy card value

*/

public int getFlippyCardValue(){

//TODO: Fill in good stuff here!

return 0;

}

/**

* Whether the suit is red or not.

*

* @return whether or not the card is red

*/

public boolean isRedCard(){

//TODO: Fill in good stuff here!

return false;

}

}

Card.java import java.util.Arrays; public class WarmUp { * * Counts how many cards are hearts * @param cards an array of cards * @return the number of cards that are hearts */ public static int countHearts(Cardcards ) // TODO: fill in the method! return -1; } ** * I * Add the elements of two arrays of the same length. The function assumes that * the arrays are of the same length * @param array1 * @param array2 * @return a new array that is the element-wise sum of the input arrays public static double() addArraysSameLength(double() array, double() array2){ W/ TODO: fill in the method ! return null; } public static void reverseArray (String [] words) { } */ // TODO: write the reverseArray method, including method header and JavaDoc comments public static void main(String[] args) { 7*String) words = {"I", "love", "my", "CS", "classes", "!"); System.out.println("Before: " + Arrays.toString(words)); reverseArray(words); System.out.println("After: + Arrays.toString(words));*/ }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!