05 Mining Final - for - arrays - cupcake

Professor Ira Fay
Class 5
•
•
•
•
Mining survey
for() loops
arrays
cupcake lab



Stand up
Learn the name of someone you don’t know
Sit down

Extended deadline due today

Walkthrough?
Please post website and GitHub link to the
shared Google doc
https://docs.google.com/spreadsheets/d/1mLW
BSuBEUG6xb08D3WJqiw0eRso2Kqe37OwpDh
CJAf8


Linked from course website
 http://irafay.com/classes/CS181

Please do it today before you sleep!
 Thoughtful answers are required
 Take a moment to reflect

Mid-semester self-eval is due!

Post to The Hub
 Five College students can email me

What are your goals for this course?

How do they relate to your larger educational goals?

How were you successful in working toward these goals?

How have you struggled to make progress, and why?

What specific things did you do to contribute to the class
overall?
The self-eval is about you, and not about Ira or your peers.









Lines of code are executed in order
= is an assignment operator
Typo-intolerant
Variables
Methods
+= and ++
// comments
if()
enum
How could I display the numbers 1 to 9?
How could I display the numbers 1 to 9?
print
print
print
print
print
print
print
print
print
(“1”);
(“2”);
(“3”);
(“4”);
(“5”);
(“6”);
(“7”);
(“8”);
(“9”);
How could I display the numbers 1 to 99?
1 to 999?
// Count from 1 to 9
for (int i = 1; i < 10; i++) {
print (i);
}
// Count from 1 to 99
for (int i = 1; i < 100; i++) {
print (i);
}
// Count from 1 to 999
for (int i = 1; i < 1000; i++) {
print (i);
}
int myRoll;
// Roll a die 10 times
for (int i = 0; i < 10; i++) {
myRoll = Random.Range(1,7);
print (myRoll);
}
int myRoll;
// Roll a die 10 times
for (int i = 0; i < 10; i++) {
myRoll = Random.Range(1,7);
// what if I want to remember all rolls?
}

Arrays are a collection of objects that are the
same type
 For example, 1000 ints
 Temperature over 5 days
int[] temperatures = new int[5];
0
1
2
3
4
int[] temperatures = new int[5];
0
key or
index
1
2
3
4
temperatures[0] = 58;
58
0
key or
index
1
2
value
3
4
58
60
70
68
62
0
1
2
3
4
int[] temperatures = new int[5];
temperatures[0] = 58;
temperatures[1] = 60;
temperatures[2] = 70;
temperatures[3] = 68;
temperatures[4] = 62;
int[] temperatures = {58,60,70,68,62};
58
60
70
68
62
0
1
2
3
4
int myRoll;
// Roll a die 10 times
for (int i = 0; i < 10; i++) {
myRoll = Random.Range(1,7);
// what if I want to remember all rolls?
}
int[] myRoll = new int[10];
// Roll a die 10 times
for (int i = 0; i < 10; i++) {
myRoll[i] = Random.Range(1,7);
print(myRoll[i]);
}

Customer walks into a cupcake store and
reserves a cupcake
 Person behind the counter tells them their
reservation number

Customer decides between frosting:
 Exactly one is required
▪ Chocolate
▪ Caramel

Customer decides between toppings:
 Any/all/none are allowed
▪ Star sprinkles
▪ Round sprinkles
▪ Tube sprinkles

What if no cupcakes remain?

What if customer doesn’t want any frosting?

Two different cake flavors?

Transportation Part 1
 Walkthrough appears 48 hours from now

Completing Mining Survey

Add links to Mining spreadsheet

Isaiah + team made a game over the summer!
http://stout.hampshire.edu/~ibm13/CraftingLife
// Count from 1 to 9
for (int i = 1; i < 10; i++) {
print (i);
}
// We could also use a while() loop
int i = 1;
while (i < 10) {
print (i);
i += 1;
}



With a growth mindset, we can improve our
skills through practicing.
Learning happens over time, not instantly.
The process of learning is uncomfortable
when we’re not competent yet.

What files Unity creates

What files are most important