Professional Documents
Culture Documents
Lab Assignment 06 2020 - 2021 Fall, CMPE 211 Fundamentals of Programming II Drawing Tool - Part One
Lab Assignment 06 2020 - 2021 Fall, CMPE 211 Fundamentals of Programming II Drawing Tool - Part One
Lab Assignment 06
2020 – 2021 Fall, CMPE 211 Fundamentals of Programming II
Drawing Tool - Part One
In this assignment, you will write a Java program to develop a simple drawing tool. The outline of the class will
be given to you (Lab6Driver.java) and you need to complete the missing parts in this file.
The Lab6Driver will read user commands and create some shapes according to these commands. The
program will work on a two dimensional virtual coordinate system. X and Y coordinates will define a grid
where the starting point is (0,0) as below:
You will use the Point class (from the java.awt package) to represent a location in this coordinate system.
Point class has integer x and integer y instance data. This means that any Point object is defined as:
1
Computer Engineering Department
In addition to the driver class, you need to write one abstract class called Shape, 3 subclasses that extends
Shape class, and 1 interface called Movable. The class diagram of the program is as follows:
Shape class:
As the diagram shows, Shape class will have a leftTop variable to keep the left top point information for a
shape. leftTop point coordinates will be defined by the user command.
isCircular variable is to identify circular objects. This data can be false by default, and can be set to true for
circle objects.
Shape class will have a points ArrayList as well. This list will keep the ordered list of vertices (starts from
leftTop) for a shape. For each shape, calculatePoints() method will define the points and add them to the list.
For each shape, calculateArea() and calculatePerimeter() methods will calculate the area and perimeter.
2
Computer Engineering Department
3
Computer Engineering Department
For circle class, there will be only two points, leftTop and rightBottom as shown below:
User Commands:
4
Computer Engineering Department
5
Computer Engineering Department
Sample Execution:
NOTE: In the template Driver class, there are two lines with comment tag GRAPHICS. If you successfully
implement the program, you can uncomment those lines to see a graphical representation of the shapes.
More information will be given by the instructors during the lab. You need to submit your program on Moodle
without Graphics part. For example, for the sample execution above, we get the following drawings: