CS
CS110: Assignment 4 Part 1. (40 points) Write a class Square.java similar to Circle that has attributes:
● x and y the coordinates of the center of the square ● halfSide half of one side of the square ● color the color of the square.
The class should have a constructor that takes two coordinates and the side. You will need to convert the side to half side. public Square (double inputX, double inputY, double inputSide) The class should also have the following methods:
● public void draw() for drawing the square. (Used the method StdDraw.filledSquare)
● public void setColor(Color newColor) method that changes the color of the square.
● public double getArea() that returns the area of the square ● public double getPerimeter() that returns the perimeter of the square.
Part 2. (50 points) Write a tester class Snowman.java, with a main method that creates different objects of the classes Square and Circle to create a snowman. You can use your creativity to build different parts of the snowman. Print the area and perimeter of each object that you create.
Importing stdlib.jar: ● Download the jar file from: here.
https://drive.google.com/a/mix.wvu.edu/file/d/0ByG7tKHaTjMWdTdTVDZGT3BPNTg/edit ● Right click on the current project. Go to Build Path > Add External Archives. Select the
downloaded .jar file. Press Open. The library is added in your project.
What to submit? 1. Square.java 2. Snowman.java