Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modified Blackjack (21) Game You will make two web pages where one can play a modified game of blackjack. If you dont know how to

Modified Blackjack (21) Game

You will make two web pages where one can play a modified game of blackjack. If you dont know how to play dont worry. I will explain what I would like you to do. The first page will be an intro page that explains the rules of the game. On that page will be a button that you click on to take you to the actual game page. Both pages should be styled with the same external css stylesheet.

Before you even start typing on the computer, I want you to have an outline of your program on paper (or typed out in Word) explaining what your page will look like and how you are going to get each step of your program to work. Think about the following programming items we have learned so far:

  • styling with CSS
  • using variables
  • loops using the for statement
  • keeping a total inside of a loop
  • making decisions using if else statements
  • alert/confirm/prompt boxes
  • creating and calling functions
  • getting values from and entering values into text boxes in a form
  • generating random numbers
  • You will need to use all of these features in order to get your program to work.

How To Play:

In this game you will be asked if you would like to draw another card. The computer will then pick a random number between 1 and 10 for you and display them in some way (i.e. on the screen, in an alert box, in text boxes on a form, etc.) as well as providing the total of all of your cards. If the total of your cards is over 21 you automatically lose that round.

If you have 21 or less, the computer always draws 3 cards (also between 1 and 10). If the computer goes over 21 you win, if you both have the same total you draw, if the computer is higher than you (but less than or equal to 21) it wins, and if the computer is lower than you, you win.

Have the program go through 10 rounds. Keep a running total of your wins, the computers wins and the draws for both you and the computer somewhere on the screen (in a form text field).

At the end of the game state the winner and the final scores in an alert box.

Other Things You Might Need In Order To Do Your Major Project:

Converting String Values to Numeric Values

  • If you need to take the value from a text field and do math with it, you need to convert it from a string (text) to a number.
  • To do this use Number( ) and set the value equal to a variable

yourTotal= Number(document.formName.fieldName.value)

Resetting the Values in Text Fields When A Form is Refreshed

  • If you have values in a form and you hit the refresh button, the values dont clear.
  • To make these values reset you can call a function using an onLoad event handler in the BODY tag of your web page.

  • The function that is called can then set the value of every text field to "" or to "0"

function startUp() {

document.formName.fieldName.value=""

}

Tips:

  • Set up the layout of your pages using HTML and CSS
  • Get the game to work for one round first without scoring
  • Scoring can be added in after you get the first round to work
  • Once this works you can make the program loop 10 times in order to play 10 games
  • Every time you get part of your program to work, make a backup copy and then keep working

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

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions

Question

b. A workshop on stress management sponsored by the company

Answered: 1 week ago

Question

3. Is IBMs program really a mentoring program? Why or why not?

Answered: 1 week ago