Lab 6 En

A program for vectorial drawings has a set of primitive graphical figures:

  • line, defined by the coordinates of its extreme points
  • circle, defined by the coordinates of its central point and by its radius
  • rectangle, defined by the coordinates of two opposite corner points

For this program, we need a module to save a drawing into a file. Two file formats are possible for the beginning:

XML

    <drawing>
        <line x1="7" y1="10" x2="50" y2="20"/>
        <circle x="90" y="80" r="10"/>
        <rectangle x1="2" y1="5" x2="20" y2="50"/>
        ...
    </drawing>

JSON

    [
        {type: "line", x1:7, y1:10, x2:50, y2:20},
        {type: "circle", x:90, y:80, r:10},
        {type: "rectangle", x1:2, y1:5, x2:20, y2:50}
        ...
    ]

Requirements

  • The UML class diagram
  • Considering that the saving process prints the data on the screen, write a test program that

saves a figure in both formats