CPSC 210
B4: Data Flow

Learning Goals
-
You need to be able to determine the value of a variable…
- by reading code, and using the debugger
- by tracing the value passed into a method
- by tracing the value returned by a method
- by determining if there are duplicate references to the same object
- by understanding the scope of variables

Pod Activity (Do in Groups of 3-5)

- Each student should put away their laptops and look at the screen!
- You do not have access to this code-base
- The goal of this lesson is to slow down and follow the Debugger demo!
- Follow along with the Debugger Demo and consider the prompts the instructor asks you to consider...
Lecture Ticket Review
public class Person {
private int age;
public Person() {
this.age = 1;
}
public int getAge() {
return age;
}
public void getOlderByYears(int years) {
this.age = this.age + years;
years = years + 1;
// POINT A
}
}
public class Main {
public static void main(String[] args) {
Person jean = new Person();
int ageAmount = 3;
//POINT B
jean.getOlderByYears(ageAmount);
//POINT C
}
}public class Person {
private int age;
public Person() {
this.age = 1;
}
public int getAge() {
return age;
}
public void getOlderByYears(int years) {
this.age = this.age + years;
years = years + 1;
// POINT A
}
}
public class Main {
public static void main(String[] args) {
Person jean = new Person();
int ageAmount = 3;
//POINT B
jean.getOlderByYears(ageAmount);
//POINT C
}
}Q1



public class Person {
private int age;
public Person() {
this.age = 1;
}
public int getAge() {
return age;
}
public void getOlderByYears(int years) {
this.age = this.age + years;
years = years + 1;
// POINT A
}
}
public class Main {
public static void main(String[] args) {
Person jean = new Person();
int ageAmount = 3;
//POINT B
jean.getOlderByYears(ageAmount);
//POINT C
}
}Q2



public class Person {
private int age;
public Person() {
this.age = 1;
}
public int getAge() {
return age;
}
public void getOlderByYears(int years) {
this.age = this.age + years;
years = years + 1;
// POINT A
}
}
public class Main {
public static void main(String[] args) {
Person jean = new Person();
int ageAmount = 3;
//POINT B
jean.getOlderByYears(ageAmount);
//POINT C
}
}Q3



Lecture Lab
plus[6,2] equals 8, plus [8,5] equals 13...Expected:


Extra: Git Branching
Branch: main
Branch: myfavoriteanimal
Create
Branch
Merge
Branch

Commits
B4: Data Flow
The End - Thank You!
B4 Data Flow
By firas_moosvi
B4 Data Flow
- 181