Category Archives: Computer Science

Microbit Firia Lab Concepts

  1. Unit 1
    1. Datatypes (scroll vs show())
  2. Unit 2
    1. Variables (delay= 1000)
    2. Roman Translator Standalone Assign
  3. Unit 3
    1. while loop
  4. Unit 4
    1. break statement
  5. Unit 5
    1. Intro to lists
  6. Unit 6
    1. Lists
    2. len function
    3. random index from list (Answer Bot)
    4. Cycling through a list
    5. type function
  7. Unit 7
    1. Probability Lab
  8. Unit 8
    1. def() using functions
  9. Unit 9

Intro To CS 2019-20

I. Alice

Unit 1 

  • Complete packets #3- 8  by Thursday Wednesday 27th
    • #1 (Example tutorial)
    • #2 (skipped)
    • #3 Coach–opacity, color
    • #4 Camera and manipulating objects (turn,tumble etc)
    • #5a Alice code (how to add instructions)
    • #5b  Alice Primitive Methods
    • #6 ( camelCase,  — read only, no tutorials)
    • #7 ( primitive methods from object tree)
    • #8 (do together )
  • Project #1
    • at least 10 instructions
    • modify a ‘subpart’
    • 1 do-together statement
    • at least 3 different objects
    • Worth 7 points.
    • To get a 7/7 you must achieve the ‘wow factor’–ie go above and beyond to create a superior final project
    • you must save your file in the format of
      • lastname-assignment1
      • morris-assignment1

Unit 2

Unit 2 Packets

  • #9 (variables)
  • #10 functions vs methods

Unit 2 Assignments

All the assignments listed below are detailed on this page

  • Drag Racing
  • Spaceship Repair
  • Apollo 15
  • End of Unit Assign

Unit 3

  1. #10
  2. #11 (math Expressions)
  3. #12 (Strings and Text)
  4. Read:  Important post to understand 
  5. Read What as a String
  6. Area of Triangle Assignment (only that one assignment)
  7. #13 (booleans)
  8. #14 (relational operators) (Show me this one when you’re done with the gumdrop/fish tutorial)
    1. Skip #14 (we did this together)
  9. Complete the rest of unit 3/4 assignments
    1. Roman Translator
    2. MPG modified
    3.  Temp Convert Mod
    4.  OR , you can skip all of these and do the much much more involved “Rock Paper Scissors ” game .

Unit 4 . Loops

  • Complete Packets:
    • 15 b (The Loop Instruction)
    • 16 (The While Instruction)
  • Unit 4 assignments here

Unit 4 . Parameters and Objects [advanced] 

  • Complete Packets:
    • #18 Writing a Class Level Method
    • #20 Saving an Object to a New Class
    • #21 Stepwise Refinement (Follow the instructions carefully on this one). If your method does not seem to work, it’s probably because you switched a left leg with a right leg
    • #22 Passing Arguments
    • Assignments here 

 

Last year’s class page.

SUPA AP A [2020-21]

SUPA / AP CS  A

Objects

 

Strings

String Loop assignments

 Validate form (Loop version)

Array Fun 2 (loops)

 

Array 1 and String 1

 


 ArrayLists and Objects(Pt I)

Objects Pt II . Super and Sub classes


Recursion, Sorting and Searching

 

String

Validation Project (Non loops)

Arrays

Coding bat (as indicated)

Array Fun 2

2D arrays

 

 

codingbat

Alice Unit 5 [Objects, Parameters]

5.1: Exercise Competition:

excercise_competition_emo

Three girls Jenny, Kelly, and Barb are enrolled in an exercise class. One day after class the three decide to have a friendly competition to see how many sets of 10 repetitions of running in place each can do before getting tired. Barb decides to go first and gets tired at 10 repetitions. Kelly goes next and she gets tired at 20 repetitions. Jenny, who has been in the exercise class for the longest, goes next. She gets tired at 30 repetitions.

Create a world that suites the competition.

  • Note: Basically, you are just using a parameter to determine how many times the girl “runsInPlace”
  • Important: Each of the girls should be an instance of ExerciseGirl class that you created in chapter 5.

 

excercise compe


 

EACH Assignment below requires the use of a parameter in some way.  If you do not have a parameter, as described, you will lose a lot of credit.

 

Here is a helpful link on how to create and use parameters, in case you forget.

 


5.2 : Jumping Jacks

jumping-jacks-optimized

Add a jumpingJack method to the ExerciseGirl class. The method should make the object perform jumping jacks .

  • Important: this method should have a parameter for the number of repetitions to perform.

5.3 : Marcello The Magician:

 

Marcello the magician has finally mastered his disappearing act. To perform the act, he places several items on a table in front of him. He stands with his right arm extended over an item. He says the magic word “Alakazam, Alakazee” and the object disappears. He repeats this procedure for each object on the table. Create a world in which Marcello (an instance of the Magician class from the People Collection) demonstrates his new act . In the magician object

  • you should create two new class-level methods:
    • sayMagicWords
      • should cause Marcello to say the magic words.
    • makeDisappear
      • This method should have an object as its parameter
      • should cause Marcello to turn to face the object, say the magic words (by calling the sayMagicWords method) and then make the object disappear by setting its opacity to zero (note: for some reason the bunny object cannot be made to disappear this way!).
  • gigantaicize
    • This method should have an object as its parameter
    • the object should be made to 5 times its original size!
  • Want to get an “A+”: then create a transmute method tha
    • takes an object  parameter
    • Changes a locust to a boar (hide the one , make the other appear)
    • changes a bird to a locust

 

Prior Version

Rock Paper Scissors Part IV [Alice 2]

We are going to create a variable numWins  to keep track of how many times the user correctly beats the cpu.

  1. create a variable numWins  to keep track of how many times the user correctly beats the cpu

num-wins-var

  1.  Every time that the user wins increment the variable by adding 1 on to that variable.

how-to-add-one-to-variable-alice

This is how you increase the value of  a variable by 1.

  1. Repeat this step for each in which the user wins.
  2. At the end of each round, tell the user how many times they won. (Remember that numWins  is a number so you must use what as a string to say it)

rps-shows-numWins

Rock Paper Scissors Part III [Alice 2]

 

In the Part 2, we ended with a dilemma. If the user wants to play a second game, we need hide the objects that were chosen in the first game!

 

  1. So, at the start of the main while  loop, you should programmatically set the isShowing  of all 6 objects to false.is-showing-false-programmatically-take2

Note: all commands in alice have a duration.  Since we want all 6 objects to immediately hide, s et the duration to 0 by clicking on more and selection duration as shown below:

duration-zero

 

So, now you should have a fully functional Rock, Paper, Scissors Game that should work similar to what you can see below  (Still, there are some improvements that could be made ,see the bottom).

rock-paper-scissors-v1-done

 

 

However, there are some improvements that we should make.

 

 

 

Improvement #1 : Keep track of how many times the user beats the computer. (required)

 

 

Rock Paper Scissors Part II [Alice 2]

Part II

1 Create a variable called userChoice

2. Use the world ask user for  a number function to store the user’s choice into that variable (Note: if the user chooses a number larger than 3 or less than 1 then they entered an invalid number, something to think aboutusers-turn-rps-2

3.   Set the isShowing  property of all 3 objects to be false .  We will set the visibility to true , when the user chooses that object , later on .

objectss-isShowing-to-false2

Task #1

Objective; If the user chooses rock, we  need to show a rock; if the user chooses scissors, show a scissors, and the same for paper.

Use if/else and the value of userChoice  and set the isShowing  of either the rock , the paper or the scissors to true

Remember:

1= Rock

2= Paper

3= Scissors

if-user-choice

 

Run through the program a few times. What should we do next ?

4.

We need to show what the CPU chooses!!

So, now we need to do a few  things:

A) edit our if/else  to consider what the user chose and  what the cpu randomly chose (both/and)

B) add a second rock, paper and scissors object that represents the CPU’s choice

(note: I set the color of the CPU’s objects to red so I can more easily distinguish the cpu’s from the user choice’s objects)

C)  Set isShowing  to false for each of the cpuChoice’s objects

rps-cpu

 

directions-rps

 

For instance, if the cpu and the user both choose rock, your screen should look something like : user-and-cpu-choose-rock

5.   State who won the round or if the round was a draw :

cpu-wins-message

 

7. The last line of your loop should ask the user if they want to play again.

gamePlaying at end of loop

 

Try playing the game a few times. You will notice that there is a problem, when you play multiple times

Can you see what is wrong with our current setup? The bug only applies to multiple games. If you play a single game and close Alice, you will not notice the problem.

rps-game-no-hidden-obj

 

As you can see above, when you  start  a second game, you can still see the rock and paper that were chosen in the first game.

Can you figure out how to fix  the problem?

Go here to see how to fix it and continue on with the project.