001package template.series1;
002
003interface Series {
004        void next();
005        void print();
006}
007class SeriesFactory {
008        private SeriesFactory() {}
009        public static Series newArith() { return new ArithSeries(); }
010        public static Series newGeom()  { return new GeomSeries(); }
011}
012class ArithSeries implements Series {
013        int x;
014        int y = 1;
015        public void next()  { x++; y = y+2; }
016        public void print() { System.out.println("x=" + x + "; y=" + y); }
017}
018class GeomSeries implements Series {
019        int x;
020        int y = 1;
021        public void next()  { x++; y = y*2; }
022        public void print() { System.out.println("x=" + x + "; y=" + y); }
023}
024
025public class Main {
026        public static void main(String[] args) {
027                Series x = SeriesFactory.newGeom();
028                x.next();
029                x.next();
030                x.print();
031        }
032}