Ask a question from expert

Ask now

COMP284 Assignment 3: JavaScript Game of Chance

4 Pages1404 Words244 Views
   

Added on  2019-10-18

About This Document

COMP284 Assignment 3 requires students to develop a JavaScript program that simulates a game of chance with rounds. The assignment also requires students to submit a report comparing Perl, PHP, JavaScript and Java. The program should work without producing script errors and be accessible via a URL. The report will determine 25% of the overall mark, while the remaining 75% will be determined by the JavaScript program. Penalties apply for incorrect submission formats and exceeding page limits.

COMP284 Assignment 3: JavaScript Game of Chance

   Added on 2019-10-18

BookmarkShareRelated Documents
JavaScriptmain body startYour task for the third and final COMP284 assignment consists of the following parts:1Write a report comparing Perl, PHP, JavaScript and Java:Identify three language constructs on which Perl, PHP, and JavaScript pairwise differ syntactically (excluding the example given below) and present these in tabular form. If you identify more than three language constructs in your report, then the marks awarded for the excess language constructs will be discarded (starting with the lowest mark). Example: PerlPHPThe syntax for conditional statements is if(condition) { } elsif (condition) { } else { }The syntax for conditional statements is (condition) { } elseif (condition) { } else { }Describe what differentiates the three scripting languages Perl, PHP, JavaScript from a programming language like Java. 2Your answers should be presented as a short report of most two pages long (plus a cover sheet indicating your name, student id, and departmental user name). Sources, including the lecture notes, must be referenced. The list of references counts towards the length of the report. Make sure that you use your own words. The report must be submitted in PDF. 3Develop a JavaScript program that provides the functionality stated in theRequirements section below.4Make the system that you have created accessible and usable via the URL http://cgi.csc.liv.ac.uk/~<your user name>/game.html taking care that the access rights for the file are neither too restrictive nor too permissive.Part 1 is worth 25% (10/40) of the overall mark for this assignment. Parts 2 to 4 are together worth 75% (30/40) of the overall mark for this assignment.RequirementsThe program simulates a simple game of chance that proceeds in rounds.Before the first round, the player enters the cost of playing one round, called playCost in the following, and the number of rounds to play, called noOfRounds. Both playCost and noOfRounds are integers greater or equal to zero. If the player enters something that is not an integer greater or equal to zero, for either playCost or noOfRounds, then an error is indicated
COMP284 Assignment 3: JavaScript Game of Chance_1
and the player is required to enter a new value (or values); this is repeated until valid values for both playCost and noOfRounds have been entered. The system also maintains a balance that is zero initially.In each round of the game, the system displays three symbols, called A, B and C in the following, where each symbol is equally likely to occur. The player wins if all the symbols are the same (e.g., B B B is displayed) or all three symbols are different (e.g., B A C is displayed), otherwise the player has lost. After the three symbols have been displayed in a round, the system indicates whether the player has won or lost.An amount which is three times the cost of playing one round (i.e. 3 x playCost) is won by the player if three symbols the same are displayed. An amount of two times the cost of playing one round (i.e. 2 x playCost) is wonif the three symbols all different are displayed. In all other cases, nothing is won. At the end of each round the system adds the amount won to the balance and subtracts playCost from the balance.In addition to the three symbols and an indication whether the player has won or lost, at the end of the round the program shows the amount won in that round and the balance. There must also be a way in which the player initiates the next round of the game.After all rounds have been played the system indicates the quotient of balance and noOfRounds (remember, noOfRounds may be zero and this case has to be handled appropriately).Additional requirements and comments:The optimal solution is independent of the number of symbols that are to be displayed in a round as well as the range of letters that can be used as symbols.The visual design of the game does not need to use letters but can use any symbols or images. Remember that if you use images, then they must be your own or your use must be legal under copyright law. Youshould also provide a reference for the source or sources of your images in your design report.JavaScript engines differ from browser to browser. You should make surethat your system works in all commonly used browsers (e.g., Google Chrome, Mozilla Firefox, Microsoft Internet Explorer 9 or higher) and on all commonly used platforms (e.g., Linux derivatives and MicrosoftWindows).Your JavaScript program should only depend on your own code. JavaScript libraries/frameworks should not be used.Your code should be properly commented. This includes pointing out
COMP284 Assignment 3: JavaScript Game of Chance_2

End of preview

Want to access all the pages? Upload your documents or become a member.