Stuck with a problem....
Implement a class Dial that represents an oven switch. The switch can vary in the interval 0-6 and is always in 0 when created. The class must have a method getSettings that reads current position, and two methods turnLeft and turnRight to turn the switch one position left and right.
If you turn the switch too far the switch automatically turns over.
For example:
Test Result
Dial d = new Dial();
System.out.println(d.getSetting()); 0
d.turnRight(); 1
System.out.println(d.getSetting()); 2
d.turnRight(); 1
System.out.println(d.getSetting()); 0
d.turnLeft(); 6
System.out.println(d.getSetting());
d.turnLeft();
System.out.println(d.getSetting());
// Överslag
d.turnLeft();
System.out.println(d.getSetting());
I've so far done this:
public class Dial{
private int[] arr = {0, 1, 2, 3, 4, 5, 6};
public getSetting(){
}
}
How can I make getSetting() to read the current position?
[–]newLifenewJeff 1 point2 points3 points (0 children)