# Why is centrifugal force ‘fictitious’?

Centrifugal forces only arise when you treat a non-inertial frame of reference as if it were an inertial frame of reference. Consider what happens if I accelerate past a stationary object and I consider the motion of the object in a frame of reference in which I am at rest. I observe the object accelerate in the other direction. Since the mass of the object is constant, and Newton’s 2nd law gives F = ma, the fact that the object accelerates leads me to conclude that there must some force accelerating it. The same happens if I am in a bus which is accelerating (either by changing speed in the same direction or by changing direction). I witness the stuff, including me, accelerating around the bus but only because I am considering the bus and its contents as at rest in an inertial frame of reference.

# Nested loops: looking for duplicates in arrays

A and B are arrays of integers. Construct code to output all of the values that are in both A and B.

With questions like this, imagine you had to do it manually. Imagine you have two long lists of numbers on paper. How would you find all the values that occur in both lists?

You would probably look at the first number from list A and then scan all the way down list B to see if it’s there. If it was you’d make a note of it. Then you would get the next number from list A and do the same thing.

A computer algorithm will do exactly the same thing.

In pseudocode this is:

```loop I from 0 to A.length - 1
loop J from 0 to B.length - 1
if A[I] = B[J] then
output A[I]
end if
end loop
end loop
```

In Java it is:

```for (int i = 0; i < a.length; i++) {
for (int j = 0; j < b.length; j++) {
if (a[i] == b[j]) {
System.out.println(a[i]);
}
}
}
```

# Towards the end of the semester…

• You have three lessons to work on and complete your Greenfoot games.
• We have ICARE next week.
• Does anyone know what the plan is for the Friday of next week?
• We will do a peer review on Tuesday of the last week of the semester in which you will play and judge each others’ games according to a set of criteria.

# Basic Java Class Structure

Basic knowledge for IB Computer Science is the structure of a Java class. You should be able to create the class, its instance variables, constructor, get and set methods, and a toString() method, without even need to stop and think.

Question:

Create a Point class that has two instance variables x and y, corresponding to its coordinates on the Cartesian plane. Include an appropriate constructor that initialises these variables. Encapsulate the variables and provide a toString() method.

```public class Point {
private int x;
private int y;

public Point(int x, int y) {
setX(x);
setY(y);
}

public int getX() {
return x;
}

public int getY() {
return y;
}

public void setX(int x) {
this.x = x;
}

public void setY(int y) {
this.y = y;
}

public String toString() {
return "(" + x + "," + y +")";
}
}
```

# Hatty Japes

From Oxford University Admissions via Alex Bellos of The Guardian.

Alice, Bob and Charlie are well-known expert logicians; they always tell the truth. They are sat in a row, as illustrated above. In each of the scenarios below, their father puts a red or blue hat on each of their heads. Alice can see Bob’s and Charlie’s hats, but not her own; Bob can see only Charlie’s hat; Charlie can see none of the hats. All three of them are aware of this arrangement.

(i) Their father puts a hat on each of their heads and says: “Each of your hats is either red or blue. At least one of you has a red hat.” Alice then says “I know the colour of my hat.” What colour is each person’s hat?

(ii) Their father puts a new hat on each of their heads and again says: “Each of your hats is either red or blue. At least one of you has a red hat.” Alice then says “I don’t know the colour of my hat.” Bob then says “I don’t know the colour of my hat.” What colour is Charlie’s hat?

(iii) Their father puts a new hat on each of their heads and says: “Each of your hats is either red or blue. At least one of you has a red hat, and at least one of you has a blue hat.” Alice says “I know the colour of my hat.” Bob then says “Mine is red.” What colour is each person’s hat?

(iv) Their father puts a new hat on each of their heads and says: “Each of your hats is either red or blue. At least one of you has a red hat, and at least one of you has a blue hat.” Alice then says “I don’t know the colour of my hat.” Bob then says “My hat is red”. What colour is Charlie’s hat?

(v) Their father puts a new hat on each of their heads and says: “Each of your hats is either red or blue. Two of you who are seated adjacently both have red hats.” Alice then says “I don’t know the colour of my hat.” What colour is Charlie’s hat?

# Relativity limerick

There was a young lady named Bright,
Whose speed was far faster than light.
She set out one day,
In a relative way,
And returned home the previous night.

Attributed to A. H. Reginald Buller,
Emeritus Professor of Botany, University of Manitoba.
Royal Botanic Gardens, Kew.

# Heron’s Problem

You want to go from your home at point A, pick up some water from the river and take it to your friend’s house at point B. What is the shortest path?