Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Unit 4 Lesson 4

Name(s)_______________________________________________ Period ______ Date ___________________ 

  Activity Guide - Variables Make 


Your Goal:​ Write the code to make the Photo Liker App. You've
already been given every screen element and have comments
that will help you design your program.

Step 1 - Try using this app


● Try all of the buttons and add a comment to the picture
● Discuss with a Partner
○ What does this app do?
○ What are the inputs?
○ What are the outputs?
○ What's one piece of information that might be
stored in a variable?

Step 2 - Plan
Fill in the information in the table below for each event handler
you'll need to create

Element ID Description of What the Event Handler will Do

downButton When pressed, will subtract a like from the current like variable

upButton When pressed, will add a like from the current like variable

commentButton Triggers the event to add newCommentInput to allCommentsOutput

Fill in the table below for each variable you'll need to create.
Variable Name What the Variable Stores

Likes The number of likes

AllCommentsOutput Saves all text input from newCommentInput

Computer Science Principles 1


Unit 4 Lesson 4
Step 3 - Write Your Code
● Write the code for the app, using your plan above and the comments provided in Code Studio to help
● Step You Can Follow
○ Create all the variables from your table above.
○ Give your variables a starting value using the assignment operator (=)
○ Create blank event handlers (onEvent) for each screen element in your table above
○ Write the code to make the "upButton" work and test it out. If it's working correctly, the "Likes" count
should go up by one every time you click it
○ Write code to make the "downButton" work and test it.
○ Write code to make the "commentButton" work
○ Use your debugging skills to identify unexpected behavior and fix your program
○ Comment your code as you go, explaining what each event handler does
○ Check the Help & Tips tab for ideas about Programming Patterns you can use
● Extension Ideas
○ Set the text in "new_comment" to blank after the comment has been added
○ Add sounds to each button

Step 4 - Submit
Before you submit, check the rubric below to make sure your program meets the requirements of the task.

Category Extensive Evidence Convincing Limited Evidence No Evidence


Evidence

Code: Event onEvents are defined onEvents are defined onEvents are defined onEvents are not
Handlers Created for all the required for most of the for some of the designed for any
buttons. required buttons. buttons. buttons.

Code: Variables Variables are defined Variables are defined One variable is There are no
to store the amount to store the amount present that stores variables which store
of likes and the of likes and the either the amount of the necessary
comments. Variables comments likes or the information for the
are named in a clear comments app to work
and understandable correctly.
way.

Code: Event All necessary Most necessary Some of the None of the
Handlers Written variables are variables are necessary variables necessary variables
updated inside of the updated inside of the are updated inside of are updated inside of
onEvents. onEvents. the onEvents. the onEvents.

Code: Output The screen correctly The screen correctly The screen correctly The screen does not
Information displays the amount displays the amount displays either the display the amount
of likes and the total of likes and the total amount of likes or of likes or the
comments. Sound comments. the some amount of comments.
plays when different comments.
buttons are clicked.

Code runs without No errors are At most one error is Some errors are Many errors are
errors. present in the code. present in the code. present in the code. present in the code.

Coding Comments Comments are used Comments are used Comments are used Comments are not
to correctly explain to correctly explain to explain the present
the purpose and the purpose and purpose and function
function of all function of most of some onEvents.
onEvents. onEvents.

Computer Science Principles 2

You might also like