Advertisement
BOT_Yokel

ICS3U1 Unit 1 Activity 5: Question 1

Jul 12th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Date Completed: July 12, 2017
  2. // Purpose: Calculating sustainability of Fish according to pH of water
  3.  
  4. // This line makes the button, btnRisk wait for a mouse click
  5. // When the button is clicked, the determineEligibility function is called
  6. btnRisk.addEventListener(MouseEvent.CLICK, determinePH);
  7.  
  8. // This line makes the textinput, txtinLevel wait for a mouse click
  9. // When the textinput is clicked, the clearLabels function is called
  10. txtinLevel.addEventListener(MouseEvent.CLICK, clearLabels);
  11.  
  12. // This is the determinepH function
  13. // e:MouseEvent is the click event experienced by the button
  14. // void indicates that the function does not return a value
  15. function determinePH(e:MouseEvent):void
  16.  
  17. {
  18.     // declare the variables
  19.     var sustainability:Number;
  20.  
  21.     // get the pH level
  22.     sustainability = Number(txtinLevel.text);
  23.  
  24.  
  25.     // determine if the pH will sustain fish in water
  26.     if (sustainability <= 7.5 && sustainability >= 6.5)
  27.     {  
  28.         lblWarning.text = "NEUTRAL - FISH IN STREAMS, RIVERS AND LAKES WILL SURVIVE.";
  29.     }
  30.    
  31.     else if (sustainability > 7.5)
  32.     {
  33.         lblWarning.text = "TOO ALKALINE - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE";
  34.     }
  35.    
  36.     else if (sustainability < 6.5)
  37.     {
  38.         lblWarning.text = "TOO ACIDIC - FISH IN STREAMS, RIVERS AND LAKES WILL NOT SURVIVE";
  39.     }
  40. }
  41.  
  42. // This is the clearLabels function
  43. // e:MouseEvent is the click event experienced by the textinput
  44. // void indicates that the function does not return a value
  45. function clearLabels(e:MouseEvent):void
  46.  
  47. {
  48.     lblWarning.text = "";
  49.     txtinLevel.text = "";
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement