Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help from the private setter to end You will have to implement the class An

ID: 3648389 • Letter: N

Question

Need help from the private setter to end

You will have to implement the class Angle whose UML class diagram is presented below. The class consists of four class-level named constants that represent the conversion metrics to be used, as well as the Unicode value of the (degree) symbol. You will use this named constant when you create the string representation of the object in the method toString(). Furthermore, the seconds value must be formatted with one digit of precision, and you can use String.format("%.1f", doubleValue), any time you have to format a floating point value and convert it to a string. The three constructors will allow the client of the class to initialize the object in two ways, or use the default values as set by the class. The getters return the angular components, with the exception of getAngle() which returns the angle measurement as a fractional value, i.e. 145.1134. The two private setters perform the object mutation. They update the object according to the information provided in the parameter list. The one argument version must convert the singular value into its respective parts (degrees, minutes, seconds). Here is where you will use the conversion named constants defined in the class. Warning: An angle may be negative, thus you must use Math.abs() to obtain the positive value when needed. If an angle measurement is -101.3428, then the parts are -100degree, 20?, 34?. The five public setters will each call one of the two private setters, again based on the parameters they expect. Having the public setters call the private setters assures that all calls go through the private setters, which are the ones that actually mutate (update) the object. The addAngle method adds the parameter object to the receiving object to create a new object that holds the sum of the two angle measurements. This new object is then returned. Similarly the subtractAngle method subtracts the parameter object from the receiving object. In both these methods, the receiving object is never changed. The toString method returns the object formatted as d degree m? s?. The seconds will have 1 digit of precision. The Main class will simply test the Angle class by instantiating some angle objects. I used the objects angle0 for a default object, angleAcute for an acute angle measurement and angleObtuse for an obtuse angle measurement. You may choose the same names if you'd like or come up with alternative, but equally meaningful names. Test each method by following the output in the screenshot below. Each output section/line may necessitate the creation/updating of one or more objects before the output is displayed. Also be aware that the private setters cannot be tested directly, but rather indirectly through the public setters. It is important that you call the private ones through the public ones for you to have exhaustively tested all your methods. Make sure that your output is as close to the one shown in the screenshot. You are attempting to reproduce the exact same output shown.

Explanation / Answer

import java.awt.*; class snowperson { private int xCoor; private int yCoor; private int width; private int height; public snowperson() { xCoor = 0; yCoor = 0; width = 0; height = 0; }//end default public snowperson(int x, int y, int wid, int hght) { xCoor = x; yCoor = y; width = wid; height = hght; }//end default public int getX() { return xCoor; } public int getY() { return yCoor; } public int getH() { return height; } public int getW() { return width; } public void drawSnowBottom(Graphics g) { g.fillOval(xCoor,yCoor,width, height); }//end draw snow bottom public void drawSnowMiddle(Graphics g) { g.fillOval(xCoor+19, yCoor-128,width-40, height-40); }//end draw snow middle public void drawSnowTop(Graphics g) { g.fillOval(xCoor+50, yCoor-211, width/2, height/2); }//end draw snow top public void drawSnowperson(Graphics g) { g.setColor(Color.white); drawSnowBottom(g); drawSnowMiddle(g); drawSnowTop(g); }//end draw snow person }//end class SnowpersonAG class snowSanta extends snowperson { public void drawHat(Graphics g) { g.setColor(Color.red); int xHat[] = {xCoor+50, xCoor+150, xCoor+160, xCoor+170, xCoor+160, xCoor+150, xCoor+125, xCoor+100, xCoor+75}; int yHat[] = {yCoor-200, yCoor-200, yCoor-180, yCoor-225, yCoor-250, yCoor-260, yCoor-250, yCoor-225, yCoor-215}; int nHat = 9; g.fillPolygon(xHat, yHat, nHat); } }//end class Hope this helps :D

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote