| using System;
class SeqApp {
public static void Main(){
IntSequence isq =
new IntCompSeq(
new IntCompSeq(
new IntInterval(3,5), new IntSingular(-7) ),
new IntCompSeq(
new IntInterval(12,7), new IntCompSeq(
new IntInterval(18,-18),
new IntInterval(3,5)
)));
Visitor min = new MinVisitor();
Visitor max = new MaxVisitor();
Visitor sum = new SumVisitor();
Console.WriteLine("Min: {0} Max: {1}", isq.Accept(min),
isq.Accept(max));
// Alternative activation of Visit methods:
// Console.WriteLine("Min: {0} Max: {1}", min.Visit((IntCompSeq)isq),
// max.Visit((IntCompSeq)isq));
Console.WriteLine("Sum: {0}", isq.Accept(sum));
}
} |