EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
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
a. Carly's Catering provides meals for parties and special events. In Chapters 3 and 4, you created an Event class for the company. Now, make the following changes to the class: Currently, the class contains a field that holds the price for an Event. Now add another field that holds the price per guest, and add a public method to return its value. Currently, the class contains a constant for the price per guest. Replace that field with two fields—a lower price per guest that is $32, and a higher price per guest that is $35. Add a new method named isLargeEvent() that returns true if the number of guests is 50 or greater and otherwise returns false. Modify the method that sets the number of guests so that a large Event (more than 50 guests) uses the lower price per guest to set the new pricePerGuest field and calculate the total Event price. A small Event uses the higher price.   Save the file as Event.java. b. In Chapter 4, you modified the EventDemo class to demonstrate two Event…
Following the example of the Circle class in Section 9.2 , design a class named Stock that contains: A string data field named symbol for the stock’s symbol. A string data field named name for the stock’s name. A double data field named previousClosingPrice that stores the stock price for the previous day. A double data field named currentPrice that stores the stock price for the current time.   A constructor that creates a stock with the specified symbol and name.   A method named getChangePercent() that returns the percentage changed from previousClosingPrice to currentPrice.   Write a test program that creates a Stock object with the stock symbol ORCL, the name ­Oracle Corporation, and the previous closing price of 34.5. Set a new current price to 34.35. Select 9 more stocks with the current prices and create objects with the current prices as previous Closing prices. After 2 or more days get the price for each stock in your list and use the currentPrice method to store the current…
In Kotlin, Write a Circle data class, with a radius as a parameter to the constructor, a custom-coded property for the area, and a sizeRatio() function that takes a reference to another Circle and returns the ratio of the radius of the instance circle (the one you call the function on) to the other circle .  Use math.pow and math.PI. Write a main() that creates a circle, prints it (which will print it's automatically generated toString()), prints its radius, creates another circle, and shows the size ratio of the two.
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
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