Example #1
0
        static void Main(string[] args)
        {
            PaintingRobot[] robots = new PaintingRobot[5];
            robots[0] = new PaintingRobot();
            robots[1] = new RobotNTimes(robots[0]);
            robots[2] = new RobotLog(robots[1]);
            robots[3] = new RobotplusN(robots[2]);
            robots[4] = new Compaund(robots[1], robots[2], robots[3]);

            foreach (var robot in robots)
            {
                Console.WriteLine($"Current robot: {robot}");
                Console.WriteLine($"Painted length in 2 time units: {robot.GetPaintedLength(2)}.");
                Console.WriteLine($"Painted length in 3 time units: {robot.GetPaintedLength(3)}.");
                Console.WriteLine("");
            }

            PaintingRobot robot2 = new PaintingRobot();

            robot2 = new RobotNTimes(robot2);
            robot2 = new RobotplusN(robot2, 10);
            robot2 = new RobotNTimes(robot2, 3);

            Console.WriteLine($"Current robot: {robot2}");
            Console.WriteLine($"Painted length in 2 time units: {robot2.GetPaintedLength(2)}.");
            Console.WriteLine($"Painted length in 3 time units: {robot2.GetPaintedLength(3)}.");
            Console.WriteLine("");
        }
Example #2
0
        public string DescriptionTemplate(string name, PaintingRobot r2)
        {
            string result = r2.ToString();

            result = result.Replace("\n", "\n\t");
            return($"{name} {this.GetPaintedLength(1)}\n(\n\t{result}\n)");
        }
Example #3
0
        public override double GetPaintedLength(double time)
        {
            double max = 0;

            foreach (var r in robots)
            {
                if (r.GetPaintedLength(time) > max)
                {
                    max  = r.GetPaintedLength(time);
                    curr = r;
                }
            }
            return(max);
        }
Example #4
0
 public RobotDecoratorNlogN(PaintingRobot robot)
 {
     this.robot = robot;
 }
Example #5
0
 public RobotDecoratorMultiply(PaintingRobot robot, double n)
 {
     this.robot = robot;
     this.n     = n;
 }
Example #6
0
 public RobotDecoratorAdd(PaintingRobot robot, double n)
 {
     this.robot = robot;
     this.n     = n;
 }
Example #7
0
 public RobotLog(PaintingRobot r) : base(r)
 {
 }
Example #8
0
 public RobotplusN(PaintingRobot r, int n1 = 1) : base(r)
 {
     this.n = n1;
 }
Example #9
0
 public RobotNTimes(PaintingRobot r, int _n = 2) : base(r)
 {
     n = _n;
 }
Example #10
0
 public RobotDecorator(PaintingRobot _robot)
 {
     robot = _robot;
 }