Question: Question example of circle class for reference to solve this question Please write in java language . Assignment #1 (2%) Posted on Jan 21, 2022

Question
Question example of circle class for reference to solve this question Please
example of circle class for reference to solve this question
write in java language . Assignment #1 (2%) Posted on Jan 21,
2022 Due Date: Tuesday Jan 25, 2022, at 11:59 PM Late submission:
Please write in java language

. Assignment #1 (2%) Posted on Jan 21, 2022 Due Date: Tuesday Jan 25, 2022, at 11:59 PM Late submission: 10% penalty per day until Friday January 28, 11:59 PM Submit to the Assignment#1 drop box in MSWord format file include screenshot of the program output Design a class named Rectangle to represent a rectangle using object-oriented concepts of abstraction, encapsulation and exception handling. Follow the example of the Circle class with exception as posted in Module 1, which is designed using object-oriented concepts and exception handling Class Rectangle contains: Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height A data field number of Olbjects to count the number of Rectangles A no-arg constructor that creates a default rectangle by referring to the constructor with arguments using this keywork. A constructor that creates a rectangle with the specified width and height Setter and getter methods to set and get width and height A method named getArea () that returns the area of this rectangle. Area = width * height A method named getPerimeter () that returns the perimeter, Perimeter - 2 (width + height), A method that returns number of rectangles objects Apply Exception handling in setter methods if height or width are set to or negative values. Program output: Draw the UML diagram for the class then implement the class. Write a TestRectangle program that creates throe Rectangle objects one with width 4 and height 40. and a second one with width 3.5 and height 35.9. and a third one with width -2 and height 20. Display the width, height, area, and perimeter of each rectangle and number of rectangles - in this order. Submission on Slate: Submit only one Single MSWord file containing text of the program code (not an image of the code) and other requirements as follow: 1. UML diagram of Rectangle class 2. Text of your code(single spaced). ... not an image of the code (Note: Apply class abstraction and encapsulation and create a test driver class TestRectangle and a Rectangle class. 3. Include screen shot of your execution screen pasted below the text of your program code Evaluation: 2 Marks 1. UML 0.5 marks 2. Coding standard and quality (indentation, spacing comments, conventions etc.): 1 mark 3. Program output screen shot: 0.5 mark 4. Penalty mark for Late submission 10% per day up to 3 days then mark oro Template of OO program with Exception ICE#10.0 Sample Class Construct Class Circle with Abstraction, Encapsulation, and Exception handling. Program prints radius and area UML Diagram + 1/ Class program CircleWithException Circle.java Circle public class Circle /** The radius of the circle -radius: double private double radius - Numberofobject: int + Circle /** The number of the objects created */ private static int number of objects = 0; + Circle(radius: double) /** Construct a circle with radius 1 * getRadius(): double public Circle 01 + setRadius(radius: double): void this(1.0): 1 - getNumberOfObjects: int + getAreal): double /** Construct a circle with a specified radius */ public Circle(double newRadius) { setRadius(new Radius): numberofobjects++; 1 /** Return radius public double getRadius) return radius: 1 /** Set a new radius public void setRadius(double newRadius) throws illegalArgumentException if (newRadius > 0) radius - newRadius: else throw new llegalArgumentException "Radius is assigned: " + newRadius + " Radius cannot be zero or negative 1 /** Return numberOfObjects public static int getNumber of objects return numberofobjects; 1 /**Return the area of this circle public double getAreal return radius" radius* 3.14159: 0 of 2 Automatic Zoom Views Test Download >> /** Set a new radius public void setkadin double meadhal thrown llegallego wadius radi news che descubre *** Return number of objects public state instrumberor retumbers Return the area of this circle public double perea! return radius radius 2.94158 /Driver Class Teede jave public class TestGirde public static void main(Stringar try Circe ct-new Circle 15 Shitem.out.printl For kaden: **ci qetRadiun) - Real egterende 1 catch(egal ArgumentErception System.out.print 1 try! Circle 2 new Circles): Sitem.out.printl"For Radia:+2xetinere 1 catchiesa Arpumanteceptioned System.out.printinel try Cirde new Circle System.out.printley Far katika * -agetais Perak Spealt 1 catch (legalArgumentException System.out.printler 1 System.out printiarumber of objects createst Citlegesentertextul Sample run For Radius: 50 A 28.53975 walang Ilegalegamentin Radius signed 50 Radius cannot be or negative java.langilegargumentaception Radiused Radius cannot be or negative Number of objects created: 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!