1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marysya [2.9K]
3 years ago
12

Create a Card class that represents a playing card. It should have an int instance variable named rank and a char variable named

suit. Give it a constructor with two parameters for initializing the two instance variables and give it a getSuit() method and a getRank() method that return the values of the two instance variables. Then create a CardTester class with a main method that creates five Cards that make up a full house (that is, three of the cards have the same rank and the other two cards have the same rank) and prints out the ranks and suits of the five Cards using the getSuit() and getRank) methods
Computers and Technology
1 answer:
Helen [10]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java. It creates the Card class and then uses it to create a full house and print out the rank and suit of every card in that hand.

class Card {

   int rank;

   char suit;

   public Card(int rank, char suit) {

       this.rank = rank;

       this.suit = suit;

   }

   public int getRank() {

       return rank;

   }

   public char getSuit() {

       return suit;

   }

}

class CardTester {

   public static void main(String[] args) {

       Card card1 = new Card(3, '♥');

       Card card2 = new Card(3, '♠');

       Card card3 = new Card(3, '♦');

       Card card4 = new Card(2, '♦');

       Card card5 = new Card(2, '♣');

       System.out.println("Card 1: " + card1.getRank() + " of " + card1.getSuit());

       System.out.println("Card 2: " + card2.getRank() + " of " + card2.getSuit());

       System.out.println("Card 3: " + card3.getRank() + " of " + card3.getSuit());

       System.out.println("Card 4: " + card4.getRank() + " of " + card4.getSuit());

       System.out.println("Card 5: " + card5.getRank() + " of " + card5.getSuit());

   }

}

You might be interested in
2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte
Oduvanchick [21]

Answer:

Following are the code to this question:

def capital(val):#defining a method that takes string value as parameter

   x=True#defining boolean variable

   r=''#defining string variable  

   for i in val:#defining loop to convert the first character into upper case

       if i.isalpha() and x:#defining condition to check input value is string

           r=r+i.upper()#change value into uppercase and hold value in r variable

           x=False#assign value false in boolean variable

       elif i=='.' or i=='?' or i=='!':#check symbols

           r=r+i#add value in r variable

           x=True#assign value True in boolean variable

       else:

           r=r+i#add all value in r variable

   return r#return r variable value

val=input()#input value in val variable

print(capital(val))#called the function which print the return value

Output:

please find the attachment.

Explanation:

  • In the above python program, a method "capital" is declared, which accepts a "val" a string value in its parameter, and inside the method one boolean "x" and one string "r" variable is used, in which r stores return value.
  • In the next step, for loop is declared, inside the loop, the conditional statement is used, in if the block it checks string value and converts the first character into upper case and assigns value false in the boolean variable.  
  • In the next step, elif block is defined that adds value in r variable and at the last, it will return function value, at the last step "val" variable is declared that input value from the user and pass into the method and print its return value.

4 0
3 years ago
Crack the secret message: Crrp, Crrp, Crrp Zh'uh jrlqj wr wkh prrq. Li brx zdqw wr wdnh d wuls, Folpe derdug pb urfnhw vkls. (hi
Bess [88]

Answer:

The answer to this cipher is ....

<u>Zoom, Zoom, Zoom We’re going to the moon. If you want to take a trip, Climb aboard my rocket ship.</u>

Its only shifted by 3 so it didn't take long to find

Hope this helps!

- Quinn

6 0
4 years ago
Is the following statement TRUE or FALSE?
Musya8 [376]

Answer:

A

Explanation:

click on typeface icon in toolbar menu

6 0
3 years ago
Question 13 (6.67 points)
Montano1993 [528]

Answer:Offers professional document appearance

Explanation:

6 0
4 years ago
Thomas Hill claims that a fruitful way to think about the badness of destroying the environment is
viktelen [127]
To think about what kind of human would choose to destroy the earth.To appeal to theories about God and care for the earth.To examine people’s intuitions about whether it is right to harmthe environment.To examine the rights that belong to the environment and act on<span>the basis of those rights</span>
3 0
3 years ago
Other questions:
  • If you were optimizing for performance and wanted to support potentially adding many new elements to an adt, then:
    12·1 answer
  • How can i save a word 2016 document as a word 2016 document?
    6·1 answer
  • To resize an embedded chart, ____. select one:
    5·1 answer
  • You have begun a new project and want to keep all of the work you're doing on the project in its own directory. You will create
    8·2 answers
  • Write a function named word_count that accepts a string as its parameter and returns the number of words in the string. A word i
    10·1 answer
  • What is the most significant issue that needs to be addressed when ensuring the proper functioning of a computer?
    7·1 answer
  • Because a chart is _______, it can be dragged to another area of the worksheet.
    13·1 answer
  • Do these devices allow you to view photos using the cloud?
    10·1 answer
  • Why is it necessary to have usernames and passwords if one is working on a network?​
    12·1 answer
  • hich of the following is different on the Cisco switch CLI for a Layer 2 switch as compared with the Cisco router CLI?a. The com
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!