Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the game of Bogart in Java using the class PolyhedralDie, which extends Die. PolyhedralDie and Die classes provided below. Rules of Bogart: Object: To

Implement the game of Bogart in Java using the class PolyhedralDie, which extends Die. PolyhedralDie and Die classes provided below.

Rules of Bogart:

Object: To be the first to either accumulate 30 chips or roll all five dice at once without rolling a 1

Setup: The pot is initially empty and all players start with no chips. New chips will be added to the pot from an inexhaustible bank

Play: When your turn begins, add one chip from the bank to the pot. Roll a 10 sided die (PolyhedralDie). If you get a 1, you have aced out and your turn ends. Otherwise, you may either take the pot or keep going. If you keep going, add 2 chips to the pot and roll 2 dice. If you roll a 1 on either die, you have aced out. Otherwise, you may keep going, this time adding 3 chips and rolling 3 dice. Continue until you either ace out, decide to take the pot, or successfully roll all 5 dice without acing out.

_______________________________________________________________________________________________________________________________

public class Die { public int topFace; public int sides; public Die() { this.topFace = 1; this.sides = 6; } public int getTopFace() { return this.topFace; } public void setTopFace(int topFace) { this.topFace = topFace; } public void roll() { this.topFace = ((int)(Math.random() * sides)) + 1; } public String toString() { return "" + topFace; } public static void main(String[] args) { Die d = new Die(); PolyhedralDie pD = new PolyhedralDie (10); System.out.println("Regular 6 sided Die:"); System.out.println("Before rolling: " + d.getTopFace()); d.roll(); System.out.println("After rolling: " + d.getTopFace()); System.out.println(); System.out.println("10 sided Polyhedral Die:"); System.out.println("Before rolling: " + pD.getTopFace()); pD.roll(); System.out.println("After rolling: " + pD.getTopFace()); } }

public class PolyhedralDie extends Die { public PolyhedralDie (int sides){ this.sides = 10; } }

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

6. How do histories influence the process of identity formation?

Answered: 1 week ago