Question: Please code the following in: JAVA Please use many comments so I can understand better! Full points will be awarded, thanks in advance! he Shape

Please code the following in: JAVA

Please use many comments so I can understand better!

Full points will be awarded, thanks in advance!

Please code the following in: JAVA Please use many comments so I

he Shape ClasS When designing your Square and Circle classes from last week, it would have been useful to have a template to start from, rather than starting from scratch. Let's define sucha template here, a class that will contain data items common to all Shapes (such as an X, Y, or a Color- all shapes have these elements). We'll include a few methods that won't be used by this labDriver, but don't worry...these may prove useful in the future. We'll be satisfied here with designing yet another class, even if some of the methods are just stubs for now. For our Paint program as it stands currently, all shapes will have the following data items and methods... Class Invariants .Declare 4 class invariants for the Shape class as comments and submit them o What might be a good invariant? Think about how we might use this Shape... Perhaps x and y must be nonnegative integers? TODO: declare invariants for this Shape class here and in comments. " " Data Fields Declare an x and a y. (all data here is private) Declare a Color object. * . Instance Methods . public Shape(); .public Shape(int x, int y, Color color); //remember imports for class Color .public Shape(Shape other); //copy c'tor . public String toString(); //describe your shape's x,y, color, etc. . public double getArea); //to be replaced by subclasses, return -1 here public void draw(Graphics g); //to be used by the paint program, empty for now . Sample Output a: Shape (120,0) and color:null and area:-1 b: Shape (10,140) and color:java.awt.Color[r 64,g-64,b-64] and area: -1 c: Shape (10,10) and color:java.awt.Color[r-64,g-64,b-64] and area: -1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!