Key Learnings

Object's state: Attributes of an object and their values at a given time.

Static variables and methods belong to a class, not to a specific object.

2019 FRQ Q2

public class StepTracker {
    private int lowerBound;
    private int steps;
    private int totalDays;
    private int activeDays;

    public StepTracker(int minSteps) {
        lowerBound = minSteps;
        steps = 0;
        totalDays = 0;
        activeDays = 0;
    }

    public void addDailySteps(int newSteps) {
        steps += newSteps;
        totalDays += 1;
        if (newSteps >= lowerBound) {
            activeDays += 1;
        }
    }

    public int activeDays(){
        return activeDays;
    }

    public double averageSteps() {
        if (totalDays == 0) {
            return (double) totalDays;
        }
        else {
            return (double) steps / totalDays;
        }
    }

    public static void main(String[] args){

        StepTracker tr = new StepTracker(10000);
        System.out.println(tr.activeDays());
        System.out.println(tr.averageSteps());
        tr.addDailySteps(9000);
        System.out.println(tr.averageSteps());
        tr.addDailySteps(23000);
        System.out.println(tr.activeDays());
    }
}
StepTracker.main(null);
0
0.0
9000.0
1