JavaScript. main body start. Your task for the third an

Added on - Sep 2019

Trusted by 2+ million users,
1000+ happy students everyday
Showing pages 1 to 2 of 4 pages
JavaScriptmain body startYour task for the third and final COMP284 assignment consists of thefollowing parts:1Write a report comparing Perl, PHP, JavaScript and Java:Identify three language constructs on which Perl, PHP, andJavaScript pairwise differ syntactically (excluding the examplegiven below) and present these in tabular form. If you identifymore than three language constructs in your report, then themarks awarded for the excess language constructs will bediscarded (starting with the lowest mark). Example:PerlPHPThe syntax for conditional statements isif(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 pageslong (plus a cover sheet indicating your name, student id, anddepartmental user name). Sources, including the lecture notes, mustbe referenced. The list of references counts towards the length of thereport. Make sure that you use your own words. The report must besubmitted inPDF.3Develop a JavaScript program that provides the functionality stated in theRequirements sectionbelow.4Make the system that you have created accessible and usable via theURL<your username>/game.htmltaking care that the access rights for the fileare neither too restrictive nor too permissive.Part 1 is worth 25% (10/40) of the overall mark for this assignment. Parts 2to 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 thecost of playing one round,calledplayCostin the following, andthe number of rounds to play, callednoOfRounds. BothplayCostandnoOfRoundsare integers greater or equalto zero. If the player enters something that is not an integer greater orequal to zero, for eitherplayCostornoOfRounds, then an error is indicated
and the player is required to enter a new value (or values); this is repeateduntil valid values for bothplayCostandnoOfRoundshave been entered.The system also maintains abalancethat is zero initially.In each round of the game, the system displays three symbols, called A, Band C in the following, where each symbol is equally likely to occur. Theplayer wins if all the symbols are the same (e.g., B B B is displayed) or allthree symbols are different (e.g., B A C is displayed), otherwise the playerhas lost. After the three symbols have been displayed in a round, thesystem indicates whether the player has won or lost.An amount which is three times the cost of playing one round (i.e. 3 xplayCost) is won by the player if three symbols the same are displayed. Anamount of two times the cost of playing one round (i.e. 2 xplayCost) is wonif the three symbols all different are displayed. In all other cases, nothing iswon. At the end of each round the system adds the amount won to thebalanceand subtractsplayCostfrom thebalance.In addition to the three symbols and an indication whether the player haswon or lost, at the end of the round the program shows the amount won inthat round and thebalance. There must also be a way in which the playerinitiates the next round of the game.After all rounds have been played the system indicates the quotient ofbalanceandnoOfRounds(remember,noOfRoundsmay be zero and thiscase has to be handled appropriately).Additional requirements and comments:The optimal solution is independent of the number of symbols that are tobe displayed in a round as well as the range of letters that can beused as symbols.The visual design of the game does not need to use letters but can useany symbols or images. Remember that if you use images, then theymust be your own or your use must be legal under copyright law. Youshould also provide a reference for the source or sources of yourimages 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., GoogleChrome, Mozilla Firefox, Microsoft Internet Explorer 9 or higher) andon 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
Desklib Logo
You are reading a preview
Upload your documents to download or

Become a Desklib member to get access