SlideShare a Scribd company logo
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println("Area of a1 is " + a1.findArea());
System.out.println("Perimeter of a1 is " + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? "a1 and its clone a2 have the same area"
: "a1 and its clone a2 have different areas";
System.out.println("Compare a1 and its clone a2: t " + result);
System.out.println("Hashcode of a1: " + a1.hashCode());
System.out.println("Hashcode of a2: " + a2.hashCode());
System.out.println("Displaying a1: " + a1);
System.out.println("Displaying a2: " + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
Hashcode of a1: 1808253012
Hashcode of a2: 589431969
Displaying a1: Octagon@6bc7c054
Displaying a2: Octagon@232204a1
Solution
//operating system linux,ubuntu,Mac
/*********************GeometricObject.java**********************/
public abstract class GeometricObject {
private String color = "white";
private boolean filled;
// default constructure
public GeometricObject() {
super();
// TODO Auto-generated constructor stub
}
// construct a Geometric Object
// parameterized constructure
public GeometricObject(String color, boolean filled) {
this.color = color;
this.filled = filled;
}
/** Getter method for color */
public String getColor() {
return color;
}
/** Setter method for color */
public void setColor(String color) {
this.color = color;
}
/**
* Getter method for filled. Since filled is boolean, so the gret method
* name is isFilled
*/
public boolean isFilled() {
return filled;
}
/** Setter method for filled */
public void setFilled(boolean filled) {
this.filled = filled;
}
/** Abstract method for FindArea */
public abstract double findArea();
/** Abstract method for findPerimeter */
public abstract double findPerimeter();
}
/*****************************Octagon.java**************/
public class Octagon extends GeometricObject implements Cloneable, Comparable {
private double side;
/** construct a Octagon with specified side */
public Octagon(double side) {
super();
this.side = side;
}
/** Implement the abstract method findArea in GeometricObject */
@Override
public double findArea() {
double area = (2 + 4 / Math.sqrt(2)) * side * side;
return area;
}
/** Implement the abstract method findArea in findPerimeter */
@Override
public double findPerimeter() {
double perimeter = 8 * side;
return perimeter;
}
/** Implement the compareTo method in Comparable interface */
@Override
public int compareTo(Object o) {
// TODO Auto-generated method stub
return 0;
}
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
}
/*******************App.java*******************/
public class App {
public static void main(String[] args) {
Octagon a1 = new Octagon(5);//creating object of octagon
System.out.println("Area of a1 is " + a1.findArea());
System.out.println("Perimeter of a1 is " + a1.findPerimeter());
Object a2;
try {
a2 = a1.clone();
String result = (a1.compareTo(a2) == 0) ? "a1 and its clone a2 have the same area"
: "a1 and its clone a2 have different areas";
System.out.println("Compare a1 and its clone a2: t " + result);
System.out.println("Hashcode of a1: " + a1.hashCode());
System.out.println("Hashcode of a2: " + a2.hashCode());
System.out.println("Displaying a1: " + a1);
System.out.println("Displaying a2: " + a2);
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
}
}
/*****************output***************/
gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java
gopal@gopal:~/Desktop/chegg$ javac Octagon.java
gopal@gopal:~/Desktop/chegg$ javac App.java
gopal@gopal:~/Desktop/chegg$ java App
Area of a1 is 120.71067811865476
Perimeter of a1 is 40.0
Compare a1 and its clone a2:
a1 and its clone a2 have the same area
Hashcode of a1: 1808253012
Hashcode of a2: 589431969
Displaying a1: Octagon@6bc7c054
Displaying a2: Octagon@232204a1

More Related Content

PDF
Production.javapublic class Production {    Declaring instance.pdf
PDF
java question Fill the add statement areaProject is to wo.pdf
PDF
StackInterface An interface for the ADT stack. Do not modif.pdf
PDF
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
DOCX
My java file
PDF
public class Point {   Insert your name here    private dou.pdf
PDF
Class 6 2ciclo
DOCX
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx
Production.javapublic class Production {    Declaring instance.pdf
java question Fill the add statement areaProject is to wo.pdf
StackInterface An interface for the ADT stack. Do not modif.pdf
Creat Shape classes from scratch DETAILS You will create 3 shape cla.pdf
My java file
public class Point {   Insert your name here    private dou.pdf
Class 6 2ciclo
New folderjsjfArrayStack.classpackage jsjf;publicsynchronize.docx

Similar to operating system linux,ubuntu,Mac Geometri.pdf (20)

PDF
@author public class Person{   String sname, .pdf
PDF
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
PDF
java write a program to evaluate the postfix expressionthe program.pdf
PDF
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
PDF
Polygon.javapublic class Polygon { private int numSides; priva.pdf
PDF
Polygon.javapublic class Polygon { private int numSides; priva.pdf
PDF
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
ODP
AST Transformations at JFokus
DOCX
ETM Server
PDF
In this lab, we will write an application to store a deck of cards i.pdf
PDF
PickerApp CLass.pdf
PDF
GeeCON 2012 Bad Tests, Good Tests
PDF
Tested on EclipseBoth class should be in same package.pdf
PDF
Confitura 2012 Bad Tests, Good Tests
PPTX
Design patterns
PDF
Google guava
DOCX
Algoritmos sujei
PPT
2012 JDays Bad Tests Good Tests
PDF
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
@author public class Person{   String sname, .pdf
Using NetBeansImplement a queue named QueueLL using a Linked List .pdf
java write a program to evaluate the postfix expressionthe program.pdf
BasicPizza.javapublic class BasicPizza { Declaring instance .pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Polygon.javapublic class Polygon { private int numSides; priva.pdf
Modify HuffmanTree.java and HuffmanNode.java to allow the user to se.pdf
AST Transformations at JFokus
ETM Server
In this lab, we will write an application to store a deck of cards i.pdf
PickerApp CLass.pdf
GeeCON 2012 Bad Tests, Good Tests
Tested on EclipseBoth class should be in same package.pdf
Confitura 2012 Bad Tests, Good Tests
Design patterns
Google guava
Algoritmos sujei
2012 JDays Bad Tests Good Tests
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-

More from aquadreammail (20)

PDF
A. In order to survive inside the body of the host, a pathogen must .pdf
PDF
10) The Correct answer is improvements in learning through hypnosis .pdf
PDF
1.1.The words ‘data’ and ‘information’ are often used as though they.pdf
PDF
1. Osmotic pressure = imRTwhere m = molality of solute, R = molar.pdf
PDF
1-Children are more susceptible to Trichurus species be it male or f.pdf
PDF
Javac code for the manager of the Jeter County softball teamimp.pdf
PDF
1) Mitochondria are known as power houses of cell. The mitochondria .pdf
PDF
the molecule is 2,2-dichloro-ethanol all carbons.pdf
PDF
Increases. Gases have higher entropy than liquids.pdf
PDF
Simple C++ program to multiply two polynomials#include iostrea.pdf
PDF
design and deliver an confirmation based academic and instruction sy.pdf
PDF
OK, let me try to talk you through this. The arro.pdf
PDF
x=input(Enter the first sequence ); l1=input(Enter the lowe.pdf
PDF
Yes , we can view .Xmzx files are encoded files that take to be un.pdf
PDF
The middle Carbon is the SP hybridized atom.SP hybrid orbitals con.pdf
PDF
The link provided by your teacher is a popular article based on the .pdf
PDF
EPO, hematopoietin, or hemopoietin, is a glycoprotein hormone that c.pdf
PDF
The answer is D) IIA buffer system must contain a weak acid and i.pdf
PDF
c. underwent morphogenesis between the early and late gastrula stage.pdf
PDF
Text Component FeaturesThe JTextComponent class is the foundation .pdf
A. In order to survive inside the body of the host, a pathogen must .pdf
10) The Correct answer is improvements in learning through hypnosis .pdf
1.1.The words ‘data’ and ‘information’ are often used as though they.pdf
1. Osmotic pressure = imRTwhere m = molality of solute, R = molar.pdf
1-Children are more susceptible to Trichurus species be it male or f.pdf
Javac code for the manager of the Jeter County softball teamimp.pdf
1) Mitochondria are known as power houses of cell. The mitochondria .pdf
the molecule is 2,2-dichloro-ethanol all carbons.pdf
Increases. Gases have higher entropy than liquids.pdf
Simple C++ program to multiply two polynomials#include iostrea.pdf
design and deliver an confirmation based academic and instruction sy.pdf
OK, let me try to talk you through this. The arro.pdf
x=input(Enter the first sequence ); l1=input(Enter the lowe.pdf
Yes , we can view .Xmzx files are encoded files that take to be un.pdf
The middle Carbon is the SP hybridized atom.SP hybrid orbitals con.pdf
The link provided by your teacher is a popular article based on the .pdf
EPO, hematopoietin, or hemopoietin, is a glycoprotein hormone that c.pdf
The answer is D) IIA buffer system must contain a weak acid and i.pdf
c. underwent morphogenesis between the early and late gastrula stage.pdf
Text Component FeaturesThe JTextComponent class is the foundation .pdf

Recently uploaded (20)

PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Lesson notes of climatology university.
PDF
Classroom Observation Tools for Teachers
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Presentation on HIE in infants and its manifestations
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
RMMM.pdf make it easy to upload and study
PPTX
Cell Structure & Organelles in detailed.
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Microbial diseases, their pathogenesis and prophylaxis
Chinmaya Tiranga quiz Grand Finale.pdf
Lesson notes of climatology university.
Classroom Observation Tools for Teachers
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
human mycosis Human fungal infections are called human mycosis..pptx
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
master seminar digital applications in india
Institutional Correction lecture only . . .
01-Introduction-to-Information-Management.pdf
Presentation on HIE in infants and its manifestations
Microbial disease of the cardiovascular and lymphatic systems
RMMM.pdf make it easy to upload and study
Cell Structure & Organelles in detailed.
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra

operating system linux,ubuntu,Mac Geometri.pdf

  • 1. //operating system linux,ubuntu,Mac /*********************GeometricObject.java**********************/ public abstract class GeometricObject { private String color = "white"; private boolean filled; // default constructure public GeometricObject() { super(); // TODO Auto-generated constructor stub } // construct a Geometric Object // parameterized constructure public GeometricObject(String color, boolean filled) { this.color = color; this.filled = filled; } /** Getter method for color */ public String getColor() { return color; } /** Setter method for color */ public void setColor(String color) { this.color = color; } /** * Getter method for filled. Since filled is boolean, so the gret method * name is isFilled */ public boolean isFilled() { return filled; } /** Setter method for filled */ public void setFilled(boolean filled) { this.filled = filled; }
  • 2. /** Abstract method for FindArea */ public abstract double findArea(); /** Abstract method for findPerimeter */ public abstract double findPerimeter(); } /*****************************Octagon.java**************/ public class Octagon extends GeometricObject implements Cloneable, Comparable { private double side; /** construct a Octagon with specified side */ public Octagon(double side) { super(); this.side = side; } /** Implement the abstract method findArea in GeometricObject */ @Override public double findArea() { double area = (2 + 4 / Math.sqrt(2)) * side * side; return area; } /** Implement the abstract method findArea in findPerimeter */ @Override public double findPerimeter() { double perimeter = 8 * side; return perimeter; } /** Implement the compareTo method in Comparable interface */ @Override public int compareTo(Object o) { // TODO Auto-generated method stub return 0; } public Object clone() throws CloneNotSupportedException { return super.clone(); }
  • 3. } /*******************App.java*******************/ public class App { public static void main(String[] args) { Octagon a1 = new Octagon(5);//creating object of octagon System.out.println("Area of a1 is " + a1.findArea()); System.out.println("Perimeter of a1 is " + a1.findPerimeter()); Object a2; try { a2 = a1.clone(); String result = (a1.compareTo(a2) == 0) ? "a1 and its clone a2 have the same area" : "a1 and its clone a2 have different areas"; System.out.println("Compare a1 and its clone a2: t " + result); System.out.println("Hashcode of a1: " + a1.hashCode()); System.out.println("Hashcode of a2: " + a2.hashCode()); System.out.println("Displaying a1: " + a1); System.out.println("Displaying a2: " + a2); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } } /*****************output***************/ gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java gopal@gopal:~/Desktop/chegg$ javac Octagon.java gopal@gopal:~/Desktop/chegg$ javac App.java gopal@gopal:~/Desktop/chegg$ java App Area of a1 is 120.71067811865476 Perimeter of a1 is 40.0 Compare a1 and its clone a2: a1 and its clone a2 have the same area Hashcode of a1: 1808253012 Hashcode of a2: 589431969
  • 4. Displaying a1: Octagon@6bc7c054 Displaying a2: Octagon@232204a1 Solution //operating system linux,ubuntu,Mac /*********************GeometricObject.java**********************/ public abstract class GeometricObject { private String color = "white"; private boolean filled; // default constructure public GeometricObject() { super(); // TODO Auto-generated constructor stub } // construct a Geometric Object // parameterized constructure public GeometricObject(String color, boolean filled) { this.color = color; this.filled = filled; } /** Getter method for color */ public String getColor() { return color; } /** Setter method for color */ public void setColor(String color) { this.color = color; } /** * Getter method for filled. Since filled is boolean, so the gret method * name is isFilled */ public boolean isFilled() { return filled; }
  • 5. /** Setter method for filled */ public void setFilled(boolean filled) { this.filled = filled; } /** Abstract method for FindArea */ public abstract double findArea(); /** Abstract method for findPerimeter */ public abstract double findPerimeter(); } /*****************************Octagon.java**************/ public class Octagon extends GeometricObject implements Cloneable, Comparable { private double side; /** construct a Octagon with specified side */ public Octagon(double side) { super(); this.side = side; } /** Implement the abstract method findArea in GeometricObject */ @Override public double findArea() { double area = (2 + 4 / Math.sqrt(2)) * side * side; return area; } /** Implement the abstract method findArea in findPerimeter */ @Override public double findPerimeter() { double perimeter = 8 * side; return perimeter; } /** Implement the compareTo method in Comparable interface */ @Override public int compareTo(Object o) { // TODO Auto-generated method stub return 0;
  • 6. } public Object clone() throws CloneNotSupportedException { return super.clone(); } } /*******************App.java*******************/ public class App { public static void main(String[] args) { Octagon a1 = new Octagon(5);//creating object of octagon System.out.println("Area of a1 is " + a1.findArea()); System.out.println("Perimeter of a1 is " + a1.findPerimeter()); Object a2; try { a2 = a1.clone(); String result = (a1.compareTo(a2) == 0) ? "a1 and its clone a2 have the same area" : "a1 and its clone a2 have different areas"; System.out.println("Compare a1 and its clone a2: t " + result); System.out.println("Hashcode of a1: " + a1.hashCode()); System.out.println("Hashcode of a2: " + a2.hashCode()); System.out.println("Displaying a1: " + a1); System.out.println("Displaying a2: " + a2); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } } /*****************output***************/ gopal@gopal:~/Desktop/chegg$ javac GeometricObject.java gopal@gopal:~/Desktop/chegg$ javac Octagon.java gopal@gopal:~/Desktop/chegg$ javac App.java gopal@gopal:~/Desktop/chegg$ java App Area of a1 is 120.71067811865476 Perimeter of a1 is 40.0
  • 7. Compare a1 and its clone a2: a1 and its clone a2 have the same area Hashcode of a1: 1808253012 Hashcode of a2: 589431969 Displaying a1: Octagon@6bc7c054 Displaying a2: Octagon@232204a1