MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
MindTapV2.0 for Farrell's Java Programming with 2021 Updates, 9th Edition [Instant Access], 1 term
9th Edition
ISBN: 9780357505540
Author: Farrell; Joyce
Publisher: Cengage Learning US
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 1GZ

Explanation of Solution

Program:

File name: “Card.java

//Defining Card class

class Card

{

    //Declaring variables

    int cardValue;

    String cardSuit;

    String cardRank;  

    //Defining setValue method

    public void setValue(int value)

    {

        cardValue=value;

        //Computing value

        switch(cardValue)

        {

            case 1: cardRank="Ace"; break;

            case 2: cardRank="Two"; break;

            case 3: cardRank="Three"; break;

            case 4: cardRank="Four"; break;

            case 5: cardRank="Five"; break;

            case 6: cardRank="Six"; break;

            case 7: cardRank="Seven"; break;

            case 8: cardRank="Eight"; break;

            case 9: cardRank="Nine"; break;

            case 10: cardRank="Ten"; break;

            case 11: cardRank="Jack"; break;

            case 12: cardRank="Queen"; break;

            case 13: cardRank="King"; break;

            default: cardRank=""; 

        }  

    }

    //Defining setSuit() method

    public void setSuit(String str)

    {

        //Assigning string value to suit

        cardSuit=str;

    }

}

File name: “War2.java

//Import necessary header files

import java.util...

Blurred answer
Students have asked these similar questions
Create a RightTriangle class given the following design: RightTriangle variables: base, height methods: 2 constructors, 1 that set default values and another that accepts to parameters. setBase - changes the base. Requires one parameter for base. setHeight - changes the height. Requires one parameter for height. getBase - returns the triangle base. getHeight - returns the triangle height. area - returns the area of the triangle (1/2bh) given the current base and height
Create a MagicalPotionShop class, this class needs a field called potions.    The potions field should be an ArrayList of the type Potion.    Create a MagicalPotion class, this class needs two fields one called name,    the other called effect. Both of the fields should be Strings.
Rectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables).  Remember that a Rectangle has two attributes: Length and Width.  Implement the class by creating a computer program that will ask the user about three rectangle dimensions.  The program should be able to display the total area of the three rectangle objects.  For this exercise, you are required to apply all OOP concepts that you learned in class.   Sample output: Enter Length R1:  1 Enter Width  R1:  1 Enter Length R2:  2 Enter Width  R2:  2 Enter Length R3:  3 Enter Width  R3:  3 The total area of the rectangles is 14.00   Note:  All characters in boldface are user inputs.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY