Page 1 / 4 M150B TMA – Fall 2013/2014 Cut-off date: - TopicsExpress



          

Page 1 / 4 M150B TMA – Fall 2013/2014 Cut-off date: 7-Dec-13 Total marks: 80 This TMA should be submitted to your tutor electronically through the LMS system before the cut-off date indicated above. You should write your solutions to the questions in a single word document. Head the document with your name and your Personal Identifier (ID). This TMA assesses your understanding of Units 8 (section 3), 9, 10 and 12 of M150B. It is marked out of 80, out of which 20% will be considered for the continuous assessment grade. It consists of 4 questions. The total marks for each question are shown at the beginning of each question. The marks allocated to each part of a question are indicated in the margin. Important notes: − Before you start working with this assignment, you need to refer to section 8.2 of the M150 course companion to read about plagiarism and how to avoid it. This will help you in getting high grade in this TMA. Arab Open University Faculty of Computer Studies M150 Data, computing and information Page 2 / 4 Question 1 [20 marks] 1. Write JavaScript program according to the following: a. Define a JavaScript function occurrence(anArray,num), that takes an array anArray and a number num as arguments. The function returns the number of occurrences of num in anArray. b. Declare an array of 10 elements. c. Ask the user to enter any 10 numbers and fill them in the array. d. Print the array elements in the output window. e. Using the function occurrence(), display on the screen the number of occurrences of number 0 in the array. If the number 0 doesn’t exist in the array, you should display a suitable message also. f. Run your program two times: one where the number 0 is an element on the array and another time where the number 0 is not in the array. Provide two screenshots of the two required outputs of your program. This should also show the arrays elements. Question 2 [20 marks] In unit9, page 21 you were introduced to the methods associated with Date object. In the same unit, section 4.2 you learned how to use functions from the dateLibrary.js in JavaScript programs. The specifications for all the functions in this library are in Appendix 1 at the end of unit 9. Write JavaScript statements to do the following: a. Create a Date object representing the date 2 June 1950. b. Create another Date object representing the date 13 November 2013. c. Calculate the difference in years between the two dates and print it in the output window. d. For the Date object youve created in a. do the following: - Change the state to be 30 December 2000. You should not create a new date. - Display the day name. - Display it in long form. e. Insert a screenshot that shows the resulted output of parts c and d. f. Provide a copy of the specifications of all the functions you’ve used in writing your program. g. What information do we usually find in function specifications? Page 3 / 4 Question 3 [20 marks] You are required to model a new user-defined object type, Game. The Game object type has the following properties: name: a string representing the name of the Game. level: a string representing the level of the game, such as easy, moderate, difficult. chance: a number (from 1 to 6) representing the chance of playing the game. The Game object can go forward to further chances, however, the maximum value of chance is 6. The Game object type has the following methods: getName(): a method that returns the name of the game. getLevel(): a method that returns the level selected of the game. getChance(): a method that returns the chance of playing the game. moveForward(): a method that gives the next chance (i.e. increments chance by 1) only if the chance is less than 6. Otherwise, set it to 1. displayInfo(): a method that displays the name, level and the chance of the game in an alert box, using the three methods: getName() and getLevel() and getChance(). a. Write the Game constructor function Game(aName, aLevel, aChance). b. Implement the methods getName(),getLevel (), getChance(), and displayInfo() according to the above specifications. c. Prompt the user for values of name and level of a game he wants to create. d. Create a game instance and initialize its properties by the values entered by the user. Chance should be set to 1. e. Use an appropriate methods to: − Increment the game by two chances. − Print the game information. f. Run your program and test it to make sure it works properly. In your Solution document insert two screenshots: [3] − one showing the program prompting for the game name, with you having entered the name but not yet pressed OK; − one showing the resulted alert window. Page 4 / 4 Question 4 [20 marks] 1. Briefly define the term HCI. Whats the purpose of this kind of study? [4 marks] 2. What is a user interface? Give two examples of user interfaces you use in your daily life. [6 marks] 3. In the context of UI design, define and briefly explain (using your own understanding) the terms: visibility, affordance, tolerance and consistency. [10] Important note: In your answers to questions 1, 2 and 3, you should follow good programming style that helps readability. This includes: • Using short comment at the beginning stating the purpose of your program. • Using spacing and indentations to help make the structure of your program clear. • Following the M150 style guidelines when choosing names for the variables ( Refer to section 2.2 of unit 7 page 16)
Posted on: Mon, 02 Dec 2013 19:57:04 +0000

Trending Topics



Recently Viewed Topics




© 2015