public interface Counter{
public Counter incr();
public Counter decr();
public int value;
}
ImplementationAT
public class ImplCounter implements Counter{
int value;
public ImplCounter(){
value=0;
}
public Counter incr(){
value++;
return this;
}
public Counter decr(){
if (value>0)
value--;
return this;
}
public int value(){
return value;
}
}
Test
public class testCounter{
public static void main(String args[]){
Counter c;
c = new ImplCounter();
System.out.println(c.value());
for (int i=0;i<10;i++)
c.incr();
System.out.println(c.value());
for (int i=0;i<20;i++)
c.decr();
System.out.println(c.value());
}
}
Give the corresponding AT using a TUOPA t y p e syntax.