Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using c++ turn this code from java to OOP This task, you will create game Bars 21 or Sticks 21. There are 21 Bars and

using c++ image text in transcribed
turn this code from java to OOP This task, you will create game Bars 21 or Sticks 21. There are 21 Bars and two players A and B) in this game. The program must randomly select who is the first player (A or B). Each player can pick up the bars or sticks only 1.2 or 3. The player who picks up the ast bar(s) will loss in the game. The program MUST detect the entor and let player to pick the appropriate number of bars sticks) as shown in: import java.util. public class Main public static void main(String args Random rand new Random System.out.println("Bars 21 Game, each player picks 1.2 or 3 bars"); int randomrand.netin23-1: W/ Random number to choose first player char player1.player2 ifrandom) player = 'A: player2=8 1 else { player1=''; player2A: int Bars = 21: while Bars Bars> System.out.print("Bars Bars + Player + player1 + ' Picks: int n = rand.next Math.min Bars 32+1; Random number to choose the number of sticks. System.out.printing Barsan 1 elsel System.out.println("Player + player2+ Wint" break; 1 BarsOX System.out.print("Bars Bars Player player2 Picks: int nrand nextin Math.min(Bars.30-1: Will Random number to choose the number of sticks System.out.printinin Bars-on: 1 else System.out.println("Player player2 + Win": break

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

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago