SlideShare a Scribd company logo
GeometricObject.java
public interface GeometricObject {
//Declaring abstract methods
public double getPerimeter();
public double getArea();
}
___________________________________________
Circle.java
public class Circle implements GeometricObject {
//Declaring variable
double radius = 1.0;
//Declaring constant
public static final double PI = 3.14159;
//Parameterized constructor
public Circle(double radius) {
super();
this.radius = radius;
}
//Setters and getters
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
//getPerimeter() calculates the perimeter and return it
@Override
public double getPerimeter() {
return 2 * PI * this.radius;
}
//getArea() calculates area and return it
@Override
public double getArea() {
return PI * this.radius * this.radius;
}
}
___________________________________________
Resizable.java
public interface Resizable {
//Declaring abstract method
public void resize(int percent);
}
_________________________________________________
ResizableCircle.java
public class ResizableCircle extends Circle implements Resizable {
//parameterized ResizableObject
public ResizableCircle(double radius) {
super(radius);
}
//resize() method will change the radius of the circle based on percent
@Override
public void resize(int percent) {
double radius=getRadius();
radius=radius+((radius*percent)/100);
setRadius(radius);
}
}
___________________________________________
DriverClass.java
import java.text.DecimalFormat;
public class DriverClass {
public static void main(String[] args) {
//DecimalFormat Object is used to format the number
DecimalFormat df=new DecimalFormat("#.##");
//Creates an circle object by passing radius as parameter
Circle c=new Circle(10);
//Displaying the perimeter of the circle
System.out.println("Perimeter of the Circle :"+df.format(c.getPerimeter()));
//Displaying the area of the circle
System.out.println("Area of the Circle :"+df.format(c.getArea()));
//creating the object of the Resizable object by passing radius as parameter
ResizableCircle rc=new ResizableCircle(20);
//Displaying perimeter and area of the circle before resizing the radius
System.out.println(" _______Before Resizing the Radius_______");
System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter()));
System.out.println("Area of the Circle :"+df.format(rc.getArea()));
//Performing the resize
rc.resize(50);
//Displaying perimeter and area of the circle after resizing the radius
System.out.println(" _______After Resizing the Radius_______");
System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter()));
System.out.println("Area of the Circle :"+df.format(rc.getArea()));
}
}
________________________________________________
Output:
Perimeter of the Circle :62.83
Area of the Circle :314.16
_______Before Resizing the Radius_______
Perimeter of the Circle :125.66
Area of the Circle :1256.64
_______After Resizing the Radius_______
Perimeter of the Circle :188.5
Area of the Circle :2827.43
_______________________________________Thank YOu
Solution
GeometricObject.java
public interface GeometricObject {
//Declaring abstract methods
public double getPerimeter();
public double getArea();
}
___________________________________________
Circle.java
public class Circle implements GeometricObject {
//Declaring variable
double radius = 1.0;
//Declaring constant
public static final double PI = 3.14159;
//Parameterized constructor
public Circle(double radius) {
super();
this.radius = radius;
}
//Setters and getters
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
//getPerimeter() calculates the perimeter and return it
@Override
public double getPerimeter() {
return 2 * PI * this.radius;
}
//getArea() calculates area and return it
@Override
public double getArea() {
return PI * this.radius * this.radius;
}
}
___________________________________________
Resizable.java
public interface Resizable {
//Declaring abstract method
public void resize(int percent);
}
_________________________________________________
ResizableCircle.java
public class ResizableCircle extends Circle implements Resizable {
//parameterized ResizableObject
public ResizableCircle(double radius) {
super(radius);
}
//resize() method will change the radius of the circle based on percent
@Override
public void resize(int percent) {
double radius=getRadius();
radius=radius+((radius*percent)/100);
setRadius(radius);
}
}
___________________________________________
DriverClass.java
import java.text.DecimalFormat;
public class DriverClass {
public static void main(String[] args) {
//DecimalFormat Object is used to format the number
DecimalFormat df=new DecimalFormat("#.##");
//Creates an circle object by passing radius as parameter
Circle c=new Circle(10);
//Displaying the perimeter of the circle
System.out.println("Perimeter of the Circle :"+df.format(c.getPerimeter()));
//Displaying the area of the circle
System.out.println("Area of the Circle :"+df.format(c.getArea()));
//creating the object of the Resizable object by passing radius as parameter
ResizableCircle rc=new ResizableCircle(20);
//Displaying perimeter and area of the circle before resizing the radius
System.out.println(" _______Before Resizing the Radius_______");
System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter()));
System.out.println("Area of the Circle :"+df.format(rc.getArea()));
//Performing the resize
rc.resize(50);
//Displaying perimeter and area of the circle after resizing the radius
System.out.println(" _______After Resizing the Radius_______");
System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter()));
System.out.println("Area of the Circle :"+df.format(rc.getArea()));
}
}
________________________________________________
Output:
Perimeter of the Circle :62.83
Area of the Circle :314.16
_______Before Resizing the Radius_______
Perimeter of the Circle :125.66
Area of the Circle :1256.64
_______After Resizing the Radius_______
Perimeter of the Circle :188.5
Area of the Circle :2827.43
_______________________________________Thank YOu

More Related Content

Similar to GeometricObject.javapublic interface GeometricObject { Declari.pdf

JRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers LivesJRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers Lives
Engine Yard
 
Abstract Classes Interface Exceptional Handling Java
Abstract Classes Interface Exceptional Handling JavaAbstract Classes Interface Exceptional Handling Java
Abstract Classes Interface Exceptional Handling Java
SyedShahroseSohail
 
MultiSphere.java public class MultiSphere { public static vo.pdf
MultiSphere.java public class MultiSphere { public static vo.pdfMultiSphere.java public class MultiSphere { public static vo.pdf
MultiSphere.java public class MultiSphere { public static vo.pdf
rakeshboobna354
 
1- Create a class called Point that has two instance variables, defi.pdf
1- Create a class called Point that has two instance variables, defi.pdf1- Create a class called Point that has two instance variables, defi.pdf
1- Create a class called Point that has two instance variables, defi.pdf
jeeteshmalani1
 
Design patterns
Design patternsDesign patterns
Design patterns
Ba Tran
 
Geopy module in python
Geopy module in pythonGeopy module in python
Geopy module in python
Ashmita Dhakal
 
Csphtp1 10
Csphtp1 10Csphtp1 10
Csphtp1 10
HUST
 
3433 Ch10 Ppt
3433 Ch10 Ppt3433 Ch10 Ppt
3433 Ch10 Ppt
martha leon
 
Csphtp1 09
Csphtp1 09Csphtp1 09
Csphtp1 09
HUST
 
3433 Ch09 Ppt
3433 Ch09 Ppt3433 Ch09 Ppt
3433 Ch09 Ppt
martha leon
 
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
RihabBENLAMINE
 
ES2015 Modules
ES2015 ModulesES2015 Modules
ES2015 Modules
Joe Attardi
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
aquadreammail
 
Yield
YieldYield
Object - Oriented Programming: Inheritance
Object - Oriented Programming: InheritanceObject - Oriented Programming: Inheritance
Object - Oriented Programming: Inheritance
Andy Juan Sarango Veliz
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
ssuser562afc1
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdf
ellanorfelicityri239
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Ankitchhabra28
 

Similar to GeometricObject.javapublic interface GeometricObject { Declari.pdf (18)

JRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers LivesJRuby: Enhancing Java Developers Lives
JRuby: Enhancing Java Developers Lives
 
Abstract Classes Interface Exceptional Handling Java
Abstract Classes Interface Exceptional Handling JavaAbstract Classes Interface Exceptional Handling Java
Abstract Classes Interface Exceptional Handling Java
 
MultiSphere.java public class MultiSphere { public static vo.pdf
MultiSphere.java public class MultiSphere { public static vo.pdfMultiSphere.java public class MultiSphere { public static vo.pdf
MultiSphere.java public class MultiSphere { public static vo.pdf
 
1- Create a class called Point that has two instance variables, defi.pdf
1- Create a class called Point that has two instance variables, defi.pdf1- Create a class called Point that has two instance variables, defi.pdf
1- Create a class called Point that has two instance variables, defi.pdf
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Geopy module in python
Geopy module in pythonGeopy module in python
Geopy module in python
 
Csphtp1 10
Csphtp1 10Csphtp1 10
Csphtp1 10
 
3433 Ch10 Ppt
3433 Ch10 Ppt3433 Ch10 Ppt
3433 Ch10 Ppt
 
Csphtp1 09
Csphtp1 09Csphtp1 09
Csphtp1 09
 
3433 Ch09 Ppt
3433 Ch09 Ppt3433 Ch09 Ppt
3433 Ch09 Ppt
 
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
10_interfacesjavaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.pdf
 
ES2015 Modules
ES2015 ModulesES2015 Modules
ES2015 Modules
 
operating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdfoperating system linux,ubuntu,Mac Geometri.pdf
operating system linux,ubuntu,Mac Geometri.pdf
 
Yield
YieldYield
Yield
 
Object - Oriented Programming: Inheritance
Object - Oriented Programming: InheritanceObject - Oriented Programming: Inheritance
Object - Oriented Programming: Inheritance
 
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docxassignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
assignmentTwoCar.javaassignmentTwoCar.javapackage assignmentTw.docx
 
Martian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdfMartian Cubics and Unit TestingYou must implement all of the data .pdf
Martian Cubics and Unit TestingYou must implement all of the data .pdf
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 

More from anokhilalmobile

option E .Na2co3 hydrolysyes and gives NaoH which.pdf
                     option E .Na2co3 hydrolysyes and gives NaoH which.pdf                     option E .Na2co3 hydrolysyes and gives NaoH which.pdf
option E .Na2co3 hydrolysyes and gives NaoH which.pdf
anokhilalmobile
 
non polar molecules such as lipids and cholestrol.pdf
                     non polar molecules such as lipids and cholestrol.pdf                     non polar molecules such as lipids and cholestrol.pdf
non polar molecules such as lipids and cholestrol.pdf
anokhilalmobile
 
moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
                     moles = molarity x volume = 4.25 molL x 2.50 L =.pdf                     moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
anokhilalmobile
 
Londondispersionvan der Waals forces - these ar.pdf
                     Londondispersionvan der Waals forces - these ar.pdf                     Londondispersionvan der Waals forces - these ar.pdf
Londondispersionvan der Waals forces - these ar.pdf
anokhilalmobile
 
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
anokhilalmobile
 
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdfYou ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
anokhilalmobile
 
why would you be the best candidate for the nursing programSTATEM.pdf
why would you be the best candidate for the nursing programSTATEM.pdfwhy would you be the best candidate for the nursing programSTATEM.pdf
why would you be the best candidate for the nursing programSTATEM.pdf
anokhilalmobile
 
when the data value is passed between two different operating system.pdf
when the data value is passed between two different operating system.pdfwhen the data value is passed between two different operating system.pdf
when the data value is passed between two different operating system.pdf
anokhilalmobile
 
Using mathematical induction,STEP 1The base n = 1 is clearl.pdf
Using mathematical induction,STEP 1The base n = 1 is clearl.pdfUsing mathematical induction,STEP 1The base n = 1 is clearl.pdf
Using mathematical induction,STEP 1The base n = 1 is clearl.pdf
anokhilalmobile
 
The process include many steps which could be planning and preparati.pdf
The process include many steps which could be planning and preparati.pdfThe process include many steps which could be planning and preparati.pdf
The process include many steps which could be planning and preparati.pdf
anokhilalmobile
 
The FCPA established criminal and civil penalties for unlawful payme.pdf
The FCPA established criminal and civil penalties for unlawful payme.pdfThe FCPA established criminal and civil penalties for unlawful payme.pdf
The FCPA established criminal and civil penalties for unlawful payme.pdf
anokhilalmobile
 
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdfThe answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
anokhilalmobile
 
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdf
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdfSpontaneous mutation rates depend on the rate at which DNA transcrip.pdf
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdf
anokhilalmobile
 
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdf
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdfSales revenue100000Less- COGS60000Gross profit40000Opera.pdf
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdf
anokhilalmobile
 
D) Counterclockwise answer .pdf
                     D) Counterclockwise answer                       .pdf                     D) Counterclockwise answer                       .pdf
D) Counterclockwise answer .pdf
anokhilalmobile
 
Please give the differential equation and boundary conditions.So.pdf
Please give the differential equation and boundary conditions.So.pdfPlease give the differential equation and boundary conditions.So.pdf
Please give the differential equation and boundary conditions.So.pdf
anokhilalmobile
 
Point.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdfPoint.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdf
anokhilalmobile
 
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdfpKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
anokhilalmobile
 
Covalent bonds .pdf
                     Covalent bonds                                   .pdf                     Covalent bonds                                   .pdf
Covalent bonds .pdf
anokhilalmobile
 
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdfnaphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
anokhilalmobile
 

More from anokhilalmobile (20)

option E .Na2co3 hydrolysyes and gives NaoH which.pdf
                     option E .Na2co3 hydrolysyes and gives NaoH which.pdf                     option E .Na2co3 hydrolysyes and gives NaoH which.pdf
option E .Na2co3 hydrolysyes and gives NaoH which.pdf
 
non polar molecules such as lipids and cholestrol.pdf
                     non polar molecules such as lipids and cholestrol.pdf                     non polar molecules such as lipids and cholestrol.pdf
non polar molecules such as lipids and cholestrol.pdf
 
moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
                     moles = molarity x volume = 4.25 molL x 2.50 L =.pdf                     moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
moles = molarity x volume = 4.25 molL x 2.50 L =.pdf
 
Londondispersionvan der Waals forces - these ar.pdf
                     Londondispersionvan der Waals forces - these ar.pdf                     Londondispersionvan der Waals forces - these ar.pdf
Londondispersionvan der Waals forces - these ar.pdf
 
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
[H2SO4] = 0 because H2SO4 is a strong acid. first consider Ka2.pdf
 
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdfYou ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
You ordered a chest X-ray and saw fluid buildup in her right lung. S.pdf
 
why would you be the best candidate for the nursing programSTATEM.pdf
why would you be the best candidate for the nursing programSTATEM.pdfwhy would you be the best candidate for the nursing programSTATEM.pdf
why would you be the best candidate for the nursing programSTATEM.pdf
 
when the data value is passed between two different operating system.pdf
when the data value is passed between two different operating system.pdfwhen the data value is passed between two different operating system.pdf
when the data value is passed between two different operating system.pdf
 
Using mathematical induction,STEP 1The base n = 1 is clearl.pdf
Using mathematical induction,STEP 1The base n = 1 is clearl.pdfUsing mathematical induction,STEP 1The base n = 1 is clearl.pdf
Using mathematical induction,STEP 1The base n = 1 is clearl.pdf
 
The process include many steps which could be planning and preparati.pdf
The process include many steps which could be planning and preparati.pdfThe process include many steps which could be planning and preparati.pdf
The process include many steps which could be planning and preparati.pdf
 
The FCPA established criminal and civil penalties for unlawful payme.pdf
The FCPA established criminal and civil penalties for unlawful payme.pdfThe FCPA established criminal and civil penalties for unlawful payme.pdf
The FCPA established criminal and civil penalties for unlawful payme.pdf
 
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdfThe answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
The answer is(B.) H- and (C.) NH3Lewis bases are electron pair .pdf
 
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdf
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdfSpontaneous mutation rates depend on the rate at which DNA transcrip.pdf
Spontaneous mutation rates depend on the rate at which DNA transcrip.pdf
 
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdf
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdfSales revenue100000Less- COGS60000Gross profit40000Opera.pdf
Sales revenue100000Less- COGS60000Gross profit40000Opera.pdf
 
D) Counterclockwise answer .pdf
                     D) Counterclockwise answer                       .pdf                     D) Counterclockwise answer                       .pdf
D) Counterclockwise answer .pdf
 
Please give the differential equation and boundary conditions.So.pdf
Please give the differential equation and boundary conditions.So.pdfPlease give the differential equation and boundary conditions.So.pdf
Please give the differential equation and boundary conditions.So.pdf
 
Point.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdfPoint.javapublic class Point {    int x,y;    double m,n; .pdf
Point.javapublic class Point {    int x,y;    double m,n; .pdf
 
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdfpKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
pKa of H2PO4- is = 7.21According to Hendersons Equation ,pH = .pdf
 
Covalent bonds .pdf
                     Covalent bonds                                   .pdf                     Covalent bonds                                   .pdf
Covalent bonds .pdf
 
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdfnaphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
naphthalene, dry ice (solid co2),iodine(gentle heating), arsenic (At.pdf
 

Recently uploaded

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 

Recently uploaded (20)

The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 

GeometricObject.javapublic interface GeometricObject { Declari.pdf

  • 1. GeometricObject.java public interface GeometricObject { //Declaring abstract methods public double getPerimeter(); public double getArea(); } ___________________________________________ Circle.java public class Circle implements GeometricObject { //Declaring variable double radius = 1.0; //Declaring constant public static final double PI = 3.14159; //Parameterized constructor public Circle(double radius) { super(); this.radius = radius; } //Setters and getters public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } //getPerimeter() calculates the perimeter and return it @Override public double getPerimeter() { return 2 * PI * this.radius; } //getArea() calculates area and return it @Override
  • 2. public double getArea() { return PI * this.radius * this.radius; } } ___________________________________________ Resizable.java public interface Resizable { //Declaring abstract method public void resize(int percent); } _________________________________________________ ResizableCircle.java public class ResizableCircle extends Circle implements Resizable { //parameterized ResizableObject public ResizableCircle(double radius) { super(radius); } //resize() method will change the radius of the circle based on percent @Override public void resize(int percent) { double radius=getRadius(); radius=radius+((radius*percent)/100); setRadius(radius); } } ___________________________________________ DriverClass.java import java.text.DecimalFormat; public class DriverClass { public static void main(String[] args) { //DecimalFormat Object is used to format the number DecimalFormat df=new DecimalFormat("#.##");
  • 3. //Creates an circle object by passing radius as parameter Circle c=new Circle(10); //Displaying the perimeter of the circle System.out.println("Perimeter of the Circle :"+df.format(c.getPerimeter())); //Displaying the area of the circle System.out.println("Area of the Circle :"+df.format(c.getArea())); //creating the object of the Resizable object by passing radius as parameter ResizableCircle rc=new ResizableCircle(20); //Displaying perimeter and area of the circle before resizing the radius System.out.println(" _______Before Resizing the Radius_______"); System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter())); System.out.println("Area of the Circle :"+df.format(rc.getArea())); //Performing the resize rc.resize(50); //Displaying perimeter and area of the circle after resizing the radius System.out.println(" _______After Resizing the Radius_______"); System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter())); System.out.println("Area of the Circle :"+df.format(rc.getArea())); } } ________________________________________________ Output: Perimeter of the Circle :62.83 Area of the Circle :314.16 _______Before Resizing the Radius_______ Perimeter of the Circle :125.66 Area of the Circle :1256.64 _______After Resizing the Radius_______
  • 4. Perimeter of the Circle :188.5 Area of the Circle :2827.43 _______________________________________Thank YOu Solution GeometricObject.java public interface GeometricObject { //Declaring abstract methods public double getPerimeter(); public double getArea(); } ___________________________________________ Circle.java public class Circle implements GeometricObject { //Declaring variable double radius = 1.0; //Declaring constant public static final double PI = 3.14159; //Parameterized constructor public Circle(double radius) { super(); this.radius = radius; } //Setters and getters public double getRadius() { return radius; } public void setRadius(double radius) { this.radius = radius; } //getPerimeter() calculates the perimeter and return it @Override
  • 5. public double getPerimeter() { return 2 * PI * this.radius; } //getArea() calculates area and return it @Override public double getArea() { return PI * this.radius * this.radius; } } ___________________________________________ Resizable.java public interface Resizable { //Declaring abstract method public void resize(int percent); } _________________________________________________ ResizableCircle.java public class ResizableCircle extends Circle implements Resizable { //parameterized ResizableObject public ResizableCircle(double radius) { super(radius); } //resize() method will change the radius of the circle based on percent @Override public void resize(int percent) { double radius=getRadius(); radius=radius+((radius*percent)/100); setRadius(radius); } } ___________________________________________ DriverClass.java import java.text.DecimalFormat; public class DriverClass {
  • 6. public static void main(String[] args) { //DecimalFormat Object is used to format the number DecimalFormat df=new DecimalFormat("#.##"); //Creates an circle object by passing radius as parameter Circle c=new Circle(10); //Displaying the perimeter of the circle System.out.println("Perimeter of the Circle :"+df.format(c.getPerimeter())); //Displaying the area of the circle System.out.println("Area of the Circle :"+df.format(c.getArea())); //creating the object of the Resizable object by passing radius as parameter ResizableCircle rc=new ResizableCircle(20); //Displaying perimeter and area of the circle before resizing the radius System.out.println(" _______Before Resizing the Radius_______"); System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter())); System.out.println("Area of the Circle :"+df.format(rc.getArea())); //Performing the resize rc.resize(50); //Displaying perimeter and area of the circle after resizing the radius System.out.println(" _______After Resizing the Radius_______"); System.out.println("Perimeter of the Circle :"+df.format(rc.getPerimeter())); System.out.println("Area of the Circle :"+df.format(rc.getArea())); } } ________________________________________________ Output: Perimeter of the Circle :62.83
  • 7. Area of the Circle :314.16 _______Before Resizing the Radius_______ Perimeter of the Circle :125.66 Area of the Circle :1256.64 _______After Resizing the Radius_______ Perimeter of the Circle :188.5 Area of the Circle :2827.43 _______________________________________Thank YOu