Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help implementing everything for the tester class. the text in red are the classes made Tester class: Main Method: This method sets up

i need help implementing everything for the tester class. the text in red are the classes made image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Tester class: Main Method: This method sets up the array of graphic objects and draws the shapes to the screen. o It will instantiate an array of GraphicObjects capable of containing 20 values. o It will set up the drawing canvas which StdDraw will use as follows: // set the scale for the x/y axis StdDraw.setCanvasSize ( 1000,1000); StdDraw. setXscale (0, 1000); StdDraw. setyscale (0, 1000); StdDraw.setPenRadius (0.02); It will prompt the user for a name of a data file, open it within a try/catch block to validate the file name . Once the file opens correctly it will call the fillArray method to read the data file line by line and creating of each child class and inserting them into the array. Once filled, the method drawList will be invoked to draw all of the shapes to the screen . Finally call the method printList You will ZIP and turn in the following classes: GraphicObject Circle Rectangle Square Ellipse ObjectOperations Tester Class GraphicObject class: This is an abstract class that represents common features and operations that can be performed of different shapes. Data members: double x & double y: This is the x - y coordinate where the shape will be drawn on the drawing canvas. This represents the CENTER of the shape Color color: This is the color that will be used to draw the shape to the screen, it will be an instance of class Color created by calling the constructor from class color which receives float values for the red, green, & blue components of the color. Operations: public GraphicObject (double newX, double newY, int red, int green, int blue) : This constructor will receive a value to initialize each of the data members. It will create an instance of class Color using the supplied red, blue, & green value. public double getX(): returns the value of the x coordinate. public double getY(); returns the value of the y coordinate. public Color getColor(): returns the value of the color attribute. public String toString(): returns a string containing the values of all data members. Color values should be specified as RGB values. (there are methods to get the red, blue, & green components of a color. These methods that are part of class Color). It must also print the "class" of the object by calling the method getClass() inherited from class Object public abstract void draw(): abstract method that draws the shape to the drawing canvas. This must be overridden in the child classes. public abstract double calculateArea(): abstract method that calculates and returns the area of the shape. This must be overridfien in the child classes. public abstract double calculate Perimeter(): abstract method that calculates and returns the perimeter of the shape. This must be overridden in the child classes. Circle class: This class represents circles, which must be defined as a subclass of class GraphicObject. Data members: double radius Operations: public Circle(double newX, double newy, int red, int green, int blue ,double newRadius): this method creates a new instance of the Circle class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled circle from StdDraw, using the data members for the shape. It must call the method "setPenColor" in StdDraw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Rectangle class: This class represents rectangles, which must be defined as a subclass of class GraphicObject. Data members: double length: This represents 1/2 of the desired length of the rectangle double width: This represents 1/2 of the desired width of the rectangle Operations: Home Draw Design Share Comments Insert A O Layout >> Styles Sensitivity Paste Font Paragraph Duplicate > Read Only To save a copy of this document, click Duplicate. Rectangle class: This class represents rectangles, which must be defined as a subclass of class GraphicObject. Data members: double length: This represents 1/2 of the desired length of the rectangle double width: This represents 1/2 of the desired width of the rectangle Operations: public Rectangle(double newX, double newY, int red, int green, int blue, double newLength, double newWidth): this method creates a new instance of the Rectangle class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled rectangle from Std Draw, using the data members for the shape. It must call the method "setPenColor" in Std Draw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Square class: This class represents Squares, which must be defined as a subclass of class GraphicObject. Page 2 of 5 1265 words Focus E D E + 119% A Paste Font Paragraph Styles Sensitivity Read Only To save a copy of this document, click Duplicate. Duplicate Square class: This class represents Squares, which must be defined as a subclass of class GraphicObject Data members: double side Length: represents half the length of one side of the square Operations: public Square(double newX, double new Y, int red, int green, int blue, double sideLength): this method creates a new instance of the Square class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled Square from Std Draw, using the data members for the shape. It must call the method "setPenColor" in StdDraw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Ellipse class: Data members: double semiMajor Axis: this value is 1/2 the length of the major axis of the ellipse. double semiMinor Axis: this value is 1/2 the length of the minor axis of the ellipse. Operations: public Ellipse(double newX, double newY, int red, int green, int blue, double newSemiMajor, double new SemiMinor): this method creates a new instance of the Ellipse class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled ellipse from Std Draw, using the data members for the shape. It must call the method "setPenColor" in Std Draw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape publie double calculate Perimeter(): calculates the perimeter of the shape Page 3 of 5 1265 words Focus I - - + 119% ObjectOperations class: This class will contain two methods which manipulate a: array of GraphicObjects. Operations: public static void fillArray( GraphicObject|| objectList, Scanner filename) O This method reads a data file containing information about shapes to be drawn to the screen. O EACH LINE IN THE DATA FILE REPRESENTS A SINGLE SHAPE. o As each line is read the data input is used to create an instance of the correct shape that is inserted onto the end of the objectList array. O The format of each line varies based on the TYPE of shape being read. o General format: Each line begins with a single character representing the type of shape being drawn, followed by the X-Y coordinate of the center of the shape followed by the Red/Blue/Green values for the color of the shape, the remainder of the line consists of a series of values specific to the shape C Circle: X Y Red Blue Green Radius R Rectangle: X Y Red Blue Green Length Width Square S X Y Red Blue Green side Length Ellipse X Y Red Blue Green SemiMinorAxis SemiMajorAxis public static void draw List( GraphicObject[] objectList) o This method iterates through the object List and calls the draw method to draw each shape to the screen. Page 4 of 5 1265 words Focus E - + 119% Tester class: Main Method: This method sets up the array of graphic objects and draws the shapes to the screen. o It will instantiate an array of GraphicObjects capable of containing 20 values. o It will set up the drawing canvas which StdDraw will use as follows: // set the scale for the x/y axis StdDraw.setCanvasSize ( 1000,1000); StdDraw. setXscale (0, 1000); StdDraw. setyscale (0, 1000); StdDraw.setPenRadius (0.02); It will prompt the user for a name of a data file, open it within a try/catch block to validate the file name . Once the file opens correctly it will call the fillArray method to read the data file line by line and creating of each child class and inserting them into the array. Once filled, the method drawList will be invoked to draw all of the shapes to the screen . Finally call the method printList You will ZIP and turn in the following classes: GraphicObject Circle Rectangle Square Ellipse ObjectOperations Tester Class GraphicObject class: This is an abstract class that represents common features and operations that can be performed of different shapes. Data members: double x & double y: This is the x - y coordinate where the shape will be drawn on the drawing canvas. This represents the CENTER of the shape Color color: This is the color that will be used to draw the shape to the screen, it will be an instance of class Color created by calling the constructor from class color which receives float values for the red, green, & blue components of the color. Operations: public GraphicObject (double newX, double newY, int red, int green, int blue) : This constructor will receive a value to initialize each of the data members. It will create an instance of class Color using the supplied red, blue, & green value. public double getX(): returns the value of the x coordinate. public double getY(); returns the value of the y coordinate. public Color getColor(): returns the value of the color attribute. public String toString(): returns a string containing the values of all data members. Color values should be specified as RGB values. (there are methods to get the red, blue, & green components of a color. These methods that are part of class Color). It must also print the "class" of the object by calling the method getClass() inherited from class Object public abstract void draw(): abstract method that draws the shape to the drawing canvas. This must be overridden in the child classes. public abstract double calculateArea(): abstract method that calculates and returns the area of the shape. This must be overridfien in the child classes. public abstract double calculate Perimeter(): abstract method that calculates and returns the perimeter of the shape. This must be overridden in the child classes. Circle class: This class represents circles, which must be defined as a subclass of class GraphicObject. Data members: double radius Operations: public Circle(double newX, double newy, int red, int green, int blue ,double newRadius): this method creates a new instance of the Circle class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled circle from StdDraw, using the data members for the shape. It must call the method "setPenColor" in StdDraw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Rectangle class: This class represents rectangles, which must be defined as a subclass of class GraphicObject. Data members: double length: This represents 1/2 of the desired length of the rectangle double width: This represents 1/2 of the desired width of the rectangle Operations: Home Draw Design Share Comments Insert A O Layout >> Styles Sensitivity Paste Font Paragraph Duplicate > Read Only To save a copy of this document, click Duplicate. Rectangle class: This class represents rectangles, which must be defined as a subclass of class GraphicObject. Data members: double length: This represents 1/2 of the desired length of the rectangle double width: This represents 1/2 of the desired width of the rectangle Operations: public Rectangle(double newX, double newY, int red, int green, int blue, double newLength, double newWidth): this method creates a new instance of the Rectangle class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled rectangle from Std Draw, using the data members for the shape. It must call the method "setPenColor" in Std Draw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Square class: This class represents Squares, which must be defined as a subclass of class GraphicObject. Page 2 of 5 1265 words Focus E D E + 119% A Paste Font Paragraph Styles Sensitivity Read Only To save a copy of this document, click Duplicate. Duplicate Square class: This class represents Squares, which must be defined as a subclass of class GraphicObject Data members: double side Length: represents half the length of one side of the square Operations: public Square(double newX, double new Y, int red, int green, int blue, double sideLength): this method creates a new instance of the Square class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled Square from Std Draw, using the data members for the shape. It must call the method "setPenColor" in StdDraw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape public double calculate Perimeter(): calculates the perimeter of the shape Ellipse class: Data members: double semiMajor Axis: this value is 1/2 the length of the major axis of the ellipse. double semiMinor Axis: this value is 1/2 the length of the minor axis of the ellipse. Operations: public Ellipse(double newX, double newY, int red, int green, int blue, double newSemiMajor, double new SemiMinor): this method creates a new instance of the Ellipse class, and must call the constructor for class GraphicObject public void draw(): Calls the method to print a filled ellipse from Std Draw, using the data members for the shape. It must call the method "setPenColor" in Std Draw to set the correct color to draw the desired shape. public double calculate Area(): calculates the area of the shape publie double calculate Perimeter(): calculates the perimeter of the shape Page 3 of 5 1265 words Focus I - - + 119% ObjectOperations class: This class will contain two methods which manipulate a: array of GraphicObjects. Operations: public static void fillArray( GraphicObject|| objectList, Scanner filename) O This method reads a data file containing information about shapes to be drawn to the screen. O EACH LINE IN THE DATA FILE REPRESENTS A SINGLE SHAPE. o As each line is read the data input is used to create an instance of the correct shape that is inserted onto the end of the objectList array. O The format of each line varies based on the TYPE of shape being read. o General format: Each line begins with a single character representing the type of shape being drawn, followed by the X-Y coordinate of the center of the shape followed by the Red/Blue/Green values for the color of the shape, the remainder of the line consists of a series of values specific to the shape C Circle: X Y Red Blue Green Radius R Rectangle: X Y Red Blue Green Length Width Square S X Y Red Blue Green side Length Ellipse X Y Red Blue Green SemiMinorAxis SemiMajorAxis public static void draw List( GraphicObject[] objectList) o This method iterates through the object List and calls the draw method to draw each shape to the screen. Page 4 of 5 1265 words Focus E - + 119%

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions