CS111 requirements blog
My blog on the requirements of CS111.
| Topic | Description | Code Review Focus | Met | Unmet |
|---|---|---|---|---|
| Control Structures | ||||
| Iteration | Use loops for game object arrays, animation frames | for, forEach, while loops |
✅ | ☐ |
| Conditionals | Implement collision detection, state transitions | if/else, nested conditions |
✅ | ☐ |
| Nested Conditions | Complex game logic (e.g., power-up + collision + direction) | Multi-level conditionals | ☐ | ✅ |
| Data Types | ||||
| Numbers | Position, velocity, score tracking | Numeric properties | ☐ | ✅ |
| Strings | Character names, sprite paths, game states | String manipulation | ✅ | ☐ |
| Booleans | Flags (isJumping, isPaused, isVulnerable) | Boolean logic | ✅ | ☐ |
| Arrays | Game object collections, level data | Array operations | ✅ | ☐ |
| Objects (JSON) | Configuration objects, sprite data | Object literals | ✅ | ☐ |
| Operators | ||||
| Mathematical | Physics calculations (gravity, velocity, collision) | +, -, *, / in physics |
✅ | ☐ |
| String Operations | Path concatenation, text display | Template literals, concatenation | ✅ | ☐ |
| Boolean Expressions | Compound conditions in game logic | &&, \|\|, ! |
✅ | ☐ |
## Here are some code runners for each lesson:
Code Runner Challenge
Classes and methods
View IPYNB Source
%%js
// CODE_RUNNER: Classes and methods
class Cat {
constructor(name) {
this.name = name;
this.hunger = 100; // 100 = full, 0 = starving
}
eat() {
this.hunger = Math.min(100, this.hunger + 30);
console.log(this.name + " eats some food. Hunger: " + this.hunger);
}
meow() {
if (this.hunger < 40) {
console.log(this.name + " meows loudly... they're hungry!");
} else {
console.log(this.name + " meows contentedly.");
}
}
}
let myCat = new Cat("Whiskers");
myCat.meow(); // contentedly
myCat.hunger = 20;
myCat.meow(); // loudly/hungry
myCat.eat(); // hunger restored
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Code Runner Challenge
Strings
View IPYNB Source
%%js
// CODE_RUNNER: Strings
// Create three strings of varying lengths
let string1 = "Hello";
let string2 = "JavaScript";
let string3 = "Programming";
// Find and print the length of each string
console.log("Lengths:");
console.log(`"${string1}" has length: ${string1.length}`);
console.log(`"${string2}" has length: ${string2.length}`);
console.log(`"${string3}" has length: ${string3.length}`);
// Find and print first and last character of each string
console.log("\nFirst and Last Characters:");
console.log(`"${string1}": first='${string1[0]}', last='${string1[string1.length-1]}'`);
console.log(`"${string2}": first='${string2[0]}', last='${string2[string2.length-1]}'`);
console.log(`"${string3}": first='${string3[0]}', last='${string3[string3.length-1]}'`);
// Concatenate all three strings into a sentence
let sentence = string1 + " " + string2 + " " + string3;
console.log("\nConcatenated sentence:");
console.log(sentence);
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...