need help with programming assignment

Discussion in 'OT Technology' started by jason612, Sep 30, 2008.

  1. jason612

    jason612 OT Supporter

    Joined:
    Sep 7, 2007
    Messages:
    1,257
    Likes Received:
    0
    Location:
    NJ
    So i have a programming assignment that was due yesterday :ugh:... but i had absolutely no idea how to code it so i really need help.
    the assignment is:
    All it needs to do is display the board, allow the user to select the tile to slide, and determine if the puzzle has been solved. This means that you need to create an HTML table consisting of 4 rows, each of which contains 4 buttons. Each button must have a unique label chosen from 1 to 15, or blank (indicating the empty slot). When the user clicks on a button the event handler needs to
    1.Determine if the button clicked is for a tile adjacent to the empty slot. If it isn’t, the user made an invalid move and your document must inform the user via an alert.
    2.If the open slot is adjacent to the clicked button, then number on the clicked button must be moved to the button for the open slot and the original location of that number must now be the open slot.
    3.Determine if after a move, the puzzle is now solved.

    i need to code it using only html, javascript, and maybe arrays but it cant be too complex. im not asking someone to write it, i just have no idea how i would go about it.

    i made a table with 4 buttons to start a simple 2x2 which gets me a good amount of points for the assignment, but i have no idea how i can have it so onclick of the button, it can check the adjacent buttons to see if any are blank and if so, swap the button with the blank one.
    if i could figure out how to do that, i can figure out how to check if its in order and print appropriate warnings if a move cant be made.

    help please :wtc:
     
  2. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
  3. jason612

    jason612 OT Supporter

    Joined:
    Sep 7, 2007
    Messages:
    1,257
    Likes Received:
    0
    Location:
    NJ
    hmm ok then for a java script function, if the parameter is functionname(form,name)
    what does form and name mean? and if i want to pass a value passed into that, for example, functionname(this.form, this) is "this" just a variable and "this.form" just the way to pass the value?
     
  4. White Stormy

    White Stormy Take that, subspace!

    Joined:
    Sep 17, 2002
    Messages:
    85,489
    Likes Received:
    70
    Location:
    Sparkopolis
    read your textbook before asking OT anything in the future.
     

Share This Page