Early CST - Early risers and Eastern timezones
Evening CST - Western timezones (and really late Eastern folks)
Calendar contains zoom links
Attend 10 ones for credit.
3 practice problems every session
focused on practical understanding of concepts covered recently in class
slides and material available after class
Small breakout rooms of working together
Work for 10-15 minutes together, feel free to use paper, whiteboards, online share tools.
Use the code playground on the 125 homepage for the interactive running
public class Book { }
public class Fiction extends Book { }
public class Romance extends Fiction { }
Up casting is going up the inheritance chain.
Romance
can be cast up to Fiction
, Book
, Object
. Fiction
can be cast up to Book
and Object
Everything can basically be cast into an Object
since everything inherits from that
In java all objects by default have toString()
, hashCode()
and equqls(Object o)
They're not often that good so we override them to work as we want using @Override
For all objects we use equals()
and for all primitives/null we use ==
Check if null
Check if correct type using instanceof
Downcast it to the right type and then check all instance variables using a mix of ==
and equals()
Don't forget @Override
Cat(Cat c) {
height = c.height;
cuteness = c.cuteness;
}
public class GradeBook {
private int[] scores;
public GradeBook(int[] values) {
scores = values;
}
}
public class GradeBook {
private int[] scores;
public GradeBook(int[] values) {
scores = values;
}
}
The above example actually yields the following, values
and scores
are both references to the same array:
public class GradeBook {
private int[] scores;
public GradeBook(int[] values) {
scores = values;
}
}
public class Bird {
public int wings = 0;
public String color = "blue";
}
void color_bird(Bird canary) {
canary.color = "yellow";
}
void redBull(Bird canary) {
canary.wings += 2;
}
Bird bigBird = new Bird();
System.out.println(bigBird.wings);
System.out.println(bigBird.color);
color_bird(bigBird);
redBull(bigBird);
System.out.println(bigBird.wings);
System.out.println(bigBird.color);
Student
with attributes grad_year
and major
.void upgrade()
that will change an only an ECE major to a CS majorvoid graduate()
that will change their grad year to 2020.public class GradeBook {
private int[] scores;
public GradeBook(int[] values) {
scores = new int[values.length];
for (int i = 0; i < values.length; i++) {
scores[i] = values[i];
}
}
}
public class Student {
private int gradYear;
private String major;
public class Student(int g, String m) {
gradYear = g;
major = m;
}
public void upgrade() {
if (major.equals("ECE")) {
major = "CS";
}
}
public void graduate() {
gradYear = 2020;
}
}