1 / 13

ICS 3U Test #1 - Solutions

ICS 3U Test #1 - Solutions. Nov. 16 th , 2010. Multiple Choice. B – not allowed spaces A – 0 (a = 10, 10 + 3 = 13, 13 – 1 = 12, 12 % 3 = 0) C – 4 (>, *, ||, ==) D – Boolean C – a == b C - None. Multiple Choice (continued). A – not, and, or A – dynamic C

tanaya
Télécharger la présentation

ICS 3U Test #1 - Solutions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ICS 3UTest #1 - Solutions Nov. 16th, 2010

  2. Multiple Choice • B – not allowed spaces • A – 0 (a = 10, 10 + 3 = 13, 13 – 1 = 12, 12 % 3 = 0) • C – 4 (>, *, ||, ==) • D – Boolean • C – a == b • C - None

  3. Multiple Choice (continued) • A – not, and, or • A – dynamic • C • A – 25 (ceil(24.69) = 25 rounds up) • A – 39 • E – None of the above (!a && !b && !c || b) AND evaluated before OR b = true !a && False && !c || true = false || true **does not matter what a and c are b = false !a && true && !c || false ** depends on what a and c are

  4. Short Answer • Four items from the toolkit that were not listed. • Mathematical Calculations • Repetition Statements • Variables (Storing Data) • Modularity

  5. Short Answer 2. Evaluate the expression: Q = false, R = true, a = 1, b = 0 !(a > b) || R && !Q && (b == 0) =!(1>0) || true && !(false) && (0 == 0) =!(true)|| true && !(false) && true =false || true && true && true =false || true =true

  6. Short Answer 3. Explain, the function of the line of code below. myButton_mc. addEventListener(MouseEvent.CLICK, goClicked); myButton_mc name of button that we are adding the event listener to addEventListener  adds an event listener to the button, basically telling CS3 to wait for the user to click myButton MouseEvent.CLICK  tells CS3 that we are waiting for the user to CLICK the button (what event we are waiting for) goClicked  the name of a function to execute once the user clicks the button

  7. Short Answer # 4 Code Errors • conevolume has been used as a variable and a function name • Replace conevolume on lines 6 & 8 with CalcVolume • Takes care of errors 1023 and 1021 • Height is a reserved word ... Need to change variable to coneheight • Lines 2, 10 and 12 – change height to coneheight • Takes care of error 1152

  8. Short Answer#4 (continued) • Need to add { to the start of the function • Insert a line after line 8 with { • Takes care of error # 1126 • Name of object – wrong capitalization • Change txtradiusin_text.text to txtRadiusIn_text.text as labelled on the screen diagram • Takes care of error # 1120 5. Missing parseFloat • Lines 9 & 10 – need to be changed to include parseFloat • Takes care of error # 1067

  9. Code Writing # 1 if (temp > 28) { trace(“Too Hot!”); } else if (temp < 15) { trace(“Too Cold!”); } else { trace(“Perfect!”); } if (temp > 28) { trace(“Too Hot!”); } else if (temp >= 15) && (temp <= 28) { trace(“Perfect!”); } else { trace(“Too Cold!”) }

  10. Code Writing #2 //declare variables var score: int; varholenum: int; var par: int; //get input score = parseInt(txtScoreIn_text.text); holenum = parseInt(txtHoleIn_text.text); //assigns par based on hole number if (holenum == 9) || (holenum >= 1) && (holenum <=4) { par = 3; } else { par = 4; }

  11. Code Writing #2 – (continued) // outputs statement based on score in relation to par if (score == 1) { txtOutput_text.text = “Hole in One!”;} else if (score == par – 2) { txtOutput_text.text = “Eagle!”; } else if (score == par – 1) { txtOutput_text.text = “Birdie”; } else if (score == par) { txtOutput_text.text = “Par!”; } else if (score == par + 1) { txtOutput_text.text = “Bogie!”; } else if (score == par + 2) { txtOutput_text.text = “Double Bogie!”; ] else { txtOutput.text_text = “Better Luck Next Time!”; }

  12. Assignment #1Mark Scheme Class did well on this assignment!

  13. Application • Programs Worked – played program, wrote a couple of comments • Also considered how well and any extra features implemented • Communication • User Interface – basically the design, intuitiveness and usability of your stage • Programming Style – comments (some need to add more), indenting (be careful ... It really adds to the readability of your code), naming (descriptive names), and white space (blank areas added into the code to add readability) • Thinking • Plan – range of test cases, sketch of layout (Stage) • Complexity of what was chosen / created

More Related