Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me to Add a cylinder class that extends circle and draw a UML diagram showing the relationship of the 3 classes package inh; public

Help me to Add a cylinder class that extends circle and draw a UML diagram showing the relationship of the 3 classes

package inh; public class Circle extends Point{ private String n; private double r; private Point center; // Circle(){ super(); n="C"; r=1; Point center = new Point(0,0); // } Circle(double r, String n, double x, double y, String ptName){ super(x,y,ptName); this.r=r; this.n=n; } // add a constructor and test it // add set and get methods for r and n // add toString() method that calls super. // add equals method // add area method // add circ method public void setr(double r) { this.r=r; } public void setn(String n) { this.n=n; } public double getr() { return r; } public String getn() { return n; } public String toString() { return super.toString() +" Radius is "+r +" Name of circle" +n; } public void computea() { a=Math.PI*r*r; } public void computec() { c=2*Math.PI*r; } public boolean equals(Circle c) { Point p=new Point(c.getx(),c.gety()); return super.equals(p) && this.r==r; } }

package inh; public class Point { private double x,y; private String name=""; Point() { // default constructor name="P"; x=0; y=0; } Point(double x, double y) { this(); this.x=x; this.y=y; } Point(double x, double y, String n) { this(x,y); name=n; } Point(String n){ name=n; } public void setx(double x) { // mutator method this.x =x; } public void sety(double y) { this.y =y; } public double getx() { return x; } public double gety() { // accesor method return y; } public void setN(String n) { name=n; } public String getN() { return name; } public String toString() { String s=name +"(" + x +"," + y+")"; return s; } public boolean equals(Point p) { return (this.x==p.x && this.y==p.y); } public double dist(Point p) { return Math.sqrt((this.x-p.x)*(this.x-p.x) + (this.y-p.y)*(this.y-p.y)); } }

package inh; public class TestC { public static void main(String[] args) { Circle c=new Circle(2,"C",5,5,"A"); System.out.println(c.toString()); Circle d=new Circle(); System.out.println(d.toString()); Point center = new Point(6,6); Circle f=new Circle(6,"C",1,2,"A"); System.out.println(f.toString()); } }

package inh; public class TestPoint { public static void main(String[] args) { Point first = new Point(); System.out.println("P: " + first); first.setx(3); first.sety(4); System.out.println("first point:" + first ) ; } }

This is all i have and tried to get more but i couldn't

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions