Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python. Please help! Make a program that takes bets on horse races. There will be four types of bets described below. The horse race

In Python. Please help!

Make a program that takes bets on horse races. There will be four types of bets described below. The horse race result is generated by a function (or class) called Race that simply scrambles the horses into random order as a psuedo/simulated horse race and that tells you the race results. You can use one of the free shuffle algorithms we will be covering in class (code will be provided) to scramble the horses/run the simulated race. We assume four horses run in a race, and we assume the horses are named by numbers 1-4. Lets say the horses are initially in the order 1 2 3 4. You are going to write a method that randomly shuffles the horses called Readysetgo. If we call Readysetgo to randomly shuffle them (thats our pseudo-race) we might get a race result of 2 1 4 3 for example, which means: horse #2 came in first, horses #1 came in second, horse #4 came in third and horse # 3 came in fourth. The user starts out with 200 dollars. Betting costs are as follows: An Exacta bet costs 10 dollars, and an Exactabox bet costing 5 dollars, a Trifecta bet costs 25 dollars, and a Trifectabox bet costs 20 dollars. We need our program to allow the user to place any of the four types of bets. The user is given a USD (US dollars) cash balance of 200 dollars for betting. The menu options allow the user to place any of the four bets, run the race, see the result, see what their cash balance is, and exit the program.

There are two easy ways to implement the user interface for this, one is going to be with a simple text based menu, and one is going to be with a simple string/command-line based menu. A text menu is where you give the user a choice of options and tell them for example: enter 1 to place an exactabet, enter 2 to place an exactabox bet, etc. ie:

Welcome to Horse Betting!

Please select from the following options 1-6

  1. Place an exact bet

  2. Place an exactabox bet

  3. Place a trifectabet

  4. Please a trifectabox bet

  5. See your USD balance

  6. Exit

etc

They then choose the option they want and then you ask them what horses they pick as the winners, get their pick, run the race, see if they won, etc. You can choose whatever way you want to create the interface.

EXACTA bets cost 10 dollars to place but you win 100 dollars if you guess the exact winning order of the top two horses.

An EXACTABOX bet costs 5 dollars to place but you win 50 if you guess the top two horses in any order.

TRIFECTA bets cost 25 dollars to place but you win 200 dollars if you guess the exact winning order of the top three horses.

An TRIFECTABOX bet costs 20 dollars to place but you win 150 if you guess the top three horses in any order.

OK here are some betting examples explained (as what it would look like in a string based menu interface)

Example Input:

EXACTA 1 3

EXACTA 1 3 means that we are betting that the winner and second place will be exactly in that order (ie; the bet is betting that horse #1 will come in first place, and horse #3 will come in second place)

EXACTABOX 1 4

EXACTABOX 1 4 means that we are betting that the winning two horses will be 1 and 4 in any order. So if the race comes in as 4 1 2 3, you still win the bet since horse number 1 and 4 are still in the top two places.

And also two more types of bet

TRIFECTA 1 3 2

TRIFECTA 1 3 2 means that we are betting that the winners will be exactly in that order (ie; the bet is saying that horse #1 will come in first place/win, horse #3 will come in second place/place, and that horse #2 will come into third place/show.

TRIFECTABOX 1 4 2

TRIFECTABOX 1 4 2 means that we are betting that the winning three horses will be 1, 4, and 2 in any order. So if the race comes in as 1 2 4 3, you still win the bet because horse number 1, 2, and 4 are in the top three places.

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

1 What demand is and what affects it.

Answered: 1 week ago