Exemplo n.º 1
0
        public void AppendLine(string line)
        {
            Point centerPoint;
            double radius;

            var parseResult = RecognizeRegex.Matches(line);

            if (parseResult.Count != 4)
            {
                throw new Exception("Can not recognize the command.");
            }

            try
            {
                this.name = parseResult[0].ToString();
                centerPoint = new Point(double.Parse(parseResult[1].ToString()), double.Parse(parseResult[2].ToString()));
                radius = double.Parse(parseResult[3].ToString());
            }
            catch (Exception)
            {
                throw new Exception("Can not recognize the command.");
            }

            if (radius <= 0)
            {
                throw new Exception("Radius <= 0");
            }

            this.circle = new CircleFigure(centerPoint, radius);
        }
Exemplo n.º 2
0
        public void MoveTest()
        {
            var circle = new CircleFigure(new Point(2, 1), 2);
            circle.Move(new Point(2, 3));

            Assert.AreEqual(circle.center, new Point(4, 4));
            Assert.AreEqual(circle.radius, 2);
        }
Exemplo n.º 3
0
        public void CloneTest()
        {
            var circle = new CircleFigure(new Point(1, 1), 1);
            var copyCircle = (CircleFigure)circle.Clone();

            Assert.AreEqual(circle.center, copyCircle.center);
            Assert.AreEqual(circle.radius, copyCircle.radius);
        }