Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please make sure to check your work before you posted it here https://onecompiler.com/java/ Playing cards are used in many computer games, including versions of such

image text in transcribedimage text in transcribed please make sure to check your work before you posted it here https://onecompiler.com/java/

Playing cards are used in many computer games, including versions of such classics as solitaire, hearts, and poker. Design a Card class that contains a character data field to hold a suit (s for spades, h or hearts, d for diamonds, or c for clubs) and an integer data field for a value from 1 to 13 . (When you learn more about string handling in the chapter "Characters, Strings, and the StringBuilder," you can modify the class to hold words for the suits, such as spades or hearts, as well as words for some of the values-for example, ace or king.) Include get and set methods for each field. Save the class as Card.java. Nrite an application that randomly selects two playing cards and displays their values. Simply assign a suit to each of the cards, but generate a random number for each card's value. Appendix D ontains information about generating random numbers. To fully understand the process, you must learn more about Java classes and methods. However, for now, you can copy the following tatements to generate a random number between 1 and 13 and assign it to a variable: inal int CARDS_IN_SUIT =13 nyValue =(( int )( Math.random ()100)% CARDS_IN_SUIT +1); After reading the chapter "Making Decisions," you will be able to have the game determine the higher card. For now, just observe how the card values change as you execute the program multiple times. Save the application as PickTwoCards.java. Lou use the Math.random( function to generate a random number. The function call uses only a class and method name-no object-so you know the random() method must be a static method. computer games often contain different characters or creatures. For example, you might design a game in which alien beings possess specific characteristics such as color, number of eyes, or number of ives. Design a character for a game, creating a class to hold at least three attributes for the character. Include methods to get and set each of the character's attributes. Save the file as MyCharacter. java. Then write an application in which you create at least two characters. In turn, pass each character to a display method that displays the character's attributes. Save the application as woCharacters.java. Greate a zip file of the .java file(s) and submit the assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Select Healthcare Classification Systems And Databases

Authors: Katherine S. Rowell, Ann Cutrell

1st Edition

0615909760, 978-0615909769

More Books

Students also viewed these Databases questions

Question

Define and measure service productivity.

Answered: 1 week ago