January 18, 2010
Study Guide for
Basic Test 3
 
 
Name________________________________________________
 
Answer the following set of questions:
 
The following code without the line numbers has been entered into the Pushbutton.action
method in REALbasic: (This code refers to Questions 1,2, and 3)
 
1)      Dim numOfClasses, grades as Integer
2)      Dim studentName as String
3)      Dim gradesTom, gradesJerry, gradesHarry as Integer
4)        
5)      grades = 0
6)      numOfClasses = 5
7)      studentName = “Jerry”
8)      gradesTom = 92
9)      gradesJerry = 78
10)  gradesHarry = 50
11)     
12)   if (studentName = “Tom”) then
13)              grades = numOfClasses * gradesTom
14)  elseif (studentName = "Jerry") then
15)              grades = numOfClasses * gradesJerry
16)   else
17)              grades = numOfClasses * gradesHarry
18)  end if
19)  editfield1.text = studentName + “  “ + str(grades)
Giving the above REALbasic code
1. What is the value of grades at line 7?
 

2.      What is the value of grades at line 19?

3.      What is the value of editfield1 after line 19 has executed?

 

4.      Write code that changes the following integer values into a text string for display in an editfield..
Dim I, J as integer
I = 4
J =10
5.      Write code that adds the following two Editfields together.
 
Dim num1, num2 as integer
Dim Answer as integer
 
Editfield1.text = “2”
Editfield2.text = “6”
  
 
6.      Write the values of I and J after the “if – then-else” statement is executed.
Dim I as Integer
Dim J as Integer
 
I = 10
J = 2
If  (I + J) = 12 then
     I= 5
     J = 5
Else
     I = 1
     J = 1
End if
7.      What color will this oval be?
canvas1.graphics.forecolor =RGB(256,0,0)
canvas1.graphics.drawOval 100, 100, 50, 50
canvas1.graphics.fillOval 100,100, 50, 50

 

 

8. List the four constructs that make up all computer programs.
 
a.       ____________________________
 
b.      _____________________________
 
c.       _____________________________
 
d.      ______________________________
 
 
9.  Draw an approximate picture of what the following line of code will look like when it has been drawn in REALbasic.
Canvas1.graphics.drawline(50,50,50,100)
 
 
 
 
10.  Do the same for Canvas1.graphics. DrawOval(50,50,40,40)
 

 


 

 

 

 
11.  Explain what each argument does in drawline. The arguments are the numbers that are between the parenthesis for example (50,50,40,40)
 
 
 
 

12.  Explain what each argument does in drawOval.

13. To move a ball along the top of a SpriteSurface or Canvas which axis would have to use x-axis or y-axis?

 

DrawOval(x,y,width, height)

14. Programmatically draw a ball at the left most top ot the Screen.

 

15. Draw the ball in the middle of the screen without using hard-coded numbers. The values of width and height are: width=40 and height= 40

 

16. Programmatically draw a tic tac toe board using only the numbers 0 and 3.

 

17. Explain how collisions work.

 

18. Name a debugging techniques that you have learned working on your house and bouncing ball project.

 

 

19. I want to move a ball across the screen 5 pixels each time through the loop how would I finish the code. BallX and BallY are integer properties initialized to 0,0. In addition you have an hspeed integer property set to 5, and a vspeed speed property set to 0;

for i = 1 to 100

DrawOval(BallX,BallY,40,40)

Next

 

20. You have a game where you need to increase a score by 1 each time the player's x position hits 50. You can assume score is an integer property that is initialized to 0.

score = 0

if (x- 5) then

fill in how to increase the score here

end if