• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

making an HTML display for a java based Craps game

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EDIT: I understand that I'm asking a lot, but I was really hoping you would pity me. I'm so close to graduating and believe it or not if I fail this class that is it. Even if I write an A thesis, if I fail this 100 lvl CS course I don't meet graduation requirements and I am already out of financial aid so there is no retaking it next semester.

Hello guys. I'm in my senior year of college and I took a 100 level CS class for funsies. Well I've pretty much neglected the entire java based section of class to focus on my thesis and now I have an assignment due tomorrow that I had put off til the last minute thinking that like the HTML part of the class I could learn and do it in a couple hours. Well I was wrong.

There are tons of java based craps games online and posts that include the code for the games in full, which we are apparently allowed to use, the problem is that she doesn't just want a craps game, she wants an html page that takes and keeps track of bets, and displays pictures of dice to demonstrate the value of someones roll, not just text. She has provided the pictures though. I just don't know how to transfer the values from the java code onto the HTML page and vice versa. How do I add the betting function into the craps game, and how do i make a text box and then input the text from text box into the betting function, then how do I take the results of the function and post them onto the java page, and how do I take the results of the dice rolls within the java game and use them to post pictures onto the html web page.
I'm completely lost. Is there anyone that could not only supply the code but explain it. I've found tons of code for very similar games that almost do all of this but it doesn't matter cause I don't understand them. and they do not explain things very well. Thank you for your time!

I'm gonna go ahead and posting all of the related information given by my teacher for clarity.

 Assignment 6:  Casino Craps
DUE:  April 24  
   You are to create from scratch a web page for playing casino craps.  You are to write your 
own HTML, CSS and Javascript code to do this;  I'm not providing any code for this 
assignment.  However, you can use any code from the slides or demos to create your page 
(and other code you find on the internet but I would suggest you only use code you 
understand).
    I have a series of slides of examples of a web page at various stages of the game.  You 
can mimic the layout and colors albeit you probably want to do your own styling.  Note that 
you need to be able to roll dice randomly (using Javascript's random function) and be able to 
display the correct two dice on the page (in pictures).  I have a zip file on Moodle of the dice 
pictures that I've used but you can use your own if you want to.  You also need to allow the 
user to enter a bet and keep track of the user's pot as well.

Rules of Casino Craps  
Start of Game: At start of game, a user is given a pot of 100 coins (or whatever you feel 
might be a useful amount). Set the bet to 0.
Place Bet: The user can make a bet at any time.  The pot is re­calculated after a win or loss 
and is based on the current bet at the time dice is done rolling.
Roll Dice: The user rolls two dice.  Use a random number function to get two numbers 
between 1 and 6.
First Roll:   The sum of the two dice are interpreted as follows:
     a.  The user wins the game if the dice add up to 11 or 7.  The bet is added to their pot.
     b.  The user loses the game if the dice add up to 2, 3 or 12.  The bet is subtracted from 
their pot.
     c.   Any other sum is called a 'point'.  Keep track of this for future rolls.  The bet and pot are
not changed.  
Point Roll:  If the user gets a 'point', from here on, the dice keeps getting rolled until this 
'point' value shows up or a 7 shows up.
      a.  If a 7 shows up, the user loses.   The bet is subtracted from their pot.
      b.  If their point shows up, the user wins. The bet is subtracted from their pot.
      c.  Any other sum is ignored.  Note that the point value is still the same as the first roll.  So
don't change the point value here.  The bet and pot are not changed either.  
Re­Play: After a win or loss, the game is over and the user should be able to re­play the 
game by just rolling the dice.
Requirements
  You free to style the web page and add other features using Javascript but you need meet 
the following requirements:
     a)  There should be a textbox on the page (no alert boxes) where the user can type in a 
bet.  You should store this value in a global variable (one declared at the top of the page) and 
you should check to see if it is valid.  'Valid' means it needs to be from 0 up to the value of the
pot.  Also check for the user typing letters into the textbox as well.
    b)  There should be a pot value displayed on the page that needs to be kept updated.  It 
should be initially set to some positive value (I've used 100 but you can use a different value).
If you want to (not required) you can give the user another textbox and allow them to set the 
pot value.  Again, store the pot value as a variable at the top of the Javascript file.
    c)  You need two <img> tags (or some way of putting two images on the page) to allow the 
user to see the results of a dice roll.  They should reflect the actual roll; you can't just put the 
same image a dice up on the web page.  
   d)  You need some means for the user to roll the dice.  This can be a button or you can 
have the user click on the dice images (or hover over them).  It should be something the user 
has control over.
  e)  Your web page should reflect the rules correctly.  The pot should be updated after every 
win/loss and the logic for win/loss should depend on which roll has happen (first roll or point 
roll).  Also, you need to accurately keep track of the point value (again, use a global variable). 
If for some reason you want to deviate from the above rules; email me ahead of time and 
explain why you need to do this.
  f)  You need to add a CSS file with some styling to the web page.  At least color the 
background, arrange and space out the elements on the page. 

The attached image is an example of her interface.
Screen-Shot-2015-04-24-at-2.26.32-AM.png
[Thumbnail for Screen-Shot-2015-04-24-at-2.26.32-AM.png]
 
Marshal
Posts: 70997
291
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

We do not hand out complete solutions, so you would have to tell us how far you have got.
 
Daking kang
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Welcome to the Ranch

We do not hand out complete solutions, so you would have to tell us how far you have got.



Well I don't have any code for what I'm asking cause I don't know how to do it.
I'm not asking for the entire assignment. I guess the first thing that I'm curious about is how to create a text input box in html and how to take the numbers inserted into that box and input them into the javascript. and then also how to display the solution from the java function back onto the html page.

Sorry I was only putting the whole thing up there for clarity.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic