SlideShare a Scribd company logo
Polygon .java
package chegg2;
public class Polygon {
// Variables
private int numSides;
private double sideLength;
private double xCord;
private double yCord;
// Default Constructor
public Polygon () {
numSides = 3;
sideLength = 5.0;
xCord = 0.0;
yCord = 0.0;
}
// Constructor
public Polygon (int pSides, double numLength, double numXCord, double numYCord) {
numSides = pSides;
sideLength = numLength;
xCord = numXCord;
yCord = numYCord;
}
// Setter
public void setSides(int mSides) {
numSides = mSides;
System.out.println("setSides() results: "+this.numSides);
}
// Getter
public int getSides() {
return numSides;
}
}
TestPolygon .java
package chegg2;
import java.util.Scanner;
public class TestPolygon {
public static void main(String[] args) {
Polygon poly[] = new Polygon[2];
Polygon poly2 = new Polygon();
poly[0] = poly2;
Scanner input = new Scanner(System.in);
for(int i=1; i<2; i++){
Polygon obj = new Polygon();
System.out.println("New Polygons");
System.out.println("--------------------------------------------------");
System.out.print("Enter Number of Sides:");
obj.setSides(input.nextInt());
poly[i] = obj;
} input.close();
System.out.println("Polygons");
System.out.println("--------------------------------------------------");
for(int i=0; i<2; i++) {
poly[i].setSides(poly[i].getSides());
}
}
}
Output:
run:
New Polygons
--------------------------------------------------
Enter Number of Sides:9
setSides() results: 9
Polygons
--------------------------------------------------
setSides() results: 3
setSides() results: 9
BUILD SUCCESSFUL (total time: 1 second)
Solution
Polygon .java
package chegg2;
public class Polygon {
// Variables
private int numSides;
private double sideLength;
private double xCord;
private double yCord;
// Default Constructor
public Polygon () {
numSides = 3;
sideLength = 5.0;
xCord = 0.0;
yCord = 0.0;
}
// Constructor
public Polygon (int pSides, double numLength, double numXCord, double numYCord) {
numSides = pSides;
sideLength = numLength;
xCord = numXCord;
yCord = numYCord;
}
// Setter
public void setSides(int mSides) {
numSides = mSides;
System.out.println("setSides() results: "+this.numSides);
}
// Getter
public int getSides() {
return numSides;
}
}
TestPolygon .java
package chegg2;
import java.util.Scanner;
public class TestPolygon {
public static void main(String[] args) {
Polygon poly[] = new Polygon[2];
Polygon poly2 = new Polygon();
poly[0] = poly2;
Scanner input = new Scanner(System.in);
for(int i=1; i<2; i++){
Polygon obj = new Polygon();
System.out.println("New Polygons");
System.out.println("--------------------------------------------------");
System.out.print("Enter Number of Sides:");
obj.setSides(input.nextInt());
poly[i] = obj;
} input.close();
System.out.println("Polygons");
System.out.println("--------------------------------------------------");
for(int i=0; i<2; i++) {
poly[i].setSides(poly[i].getSides());
}
}
}
Output:
run:
New Polygons
--------------------------------------------------
Enter Number of Sides:9
setSides() results: 9
Polygons
--------------------------------------------------
setSides() results: 3
setSides() results: 9
BUILD SUCCESSFUL (total time: 1 second)

More Related Content

Similar to Polygon .java package chegg2;public class Polygon { Var.pdf

C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewPaulo Morgado
 
Design patterns
Design patternsDesign patterns
Design patterns
Ba Tran
 
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docxch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
cravennichole326
 
AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdf
anurag1231
 
Lecture4
Lecture4Lecture4
Lecture4
rajesh0ks
 
Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corbaMohd Arif
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
First Tuesday Bergen
 
Dependency Injection for Android
Dependency Injection for AndroidDependency Injection for Android
Dependency Injection for Android
First Tuesday Bergen
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
Dmitry Sheiko
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
Domenico Briganti
 
Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdf
ShaiAlmog1
 
C++ via C#
C++ via C#C++ via C#
C++ via C#
Egor Bogatov
 
C++ Programming - 9th Study
C++ Programming - 9th StudyC++ Programming - 9th Study
C++ Programming - 9th Study
Chris Ohk
 
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
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
ArafatSahinAfridi
 
Static Analysis in IDEA
Static Analysis in IDEAStatic Analysis in IDEA
Static Analysis in IDEA
HamletDRC
 

Similar to Polygon .java package chegg2;public class Polygon { Var.pdf (20)

C# 6.0 - April 2014 preview
C# 6.0 - April 2014 previewC# 6.0 - April 2014 preview
C# 6.0 - April 2014 preview
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Manual tecnic sergi_subirats
Manual tecnic sergi_subiratsManual tecnic sergi_subirats
Manual tecnic sergi_subirats
 
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docxch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
ch12.DS_Store__MACOSXch12._.DS_Storech12section_1.D.docx
 
AnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdfAnswerNote Provided code shows several bugs, hence I implemented.pdf
AnswerNote Provided code shows several bugs, hence I implemented.pdf
 
Lecture4
Lecture4Lecture4
Lecture4
 
Lecture4
Lecture4Lecture4
Lecture4
 
Dcom vs. corba
Dcom vs. corbaDcom vs. corba
Dcom vs. corba
 
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
Dependency Injection for Android @ Ciklum speakers corner Kiev 29. May 2014
 
Dependency Injection for Android
Dependency Injection for AndroidDependency Injection for Android
Dependency Injection for Android
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Test Engine
Test EngineTest Engine
Test Engine
 
Jersey Guice AOP
Jersey Guice AOPJersey Guice AOP
Jersey Guice AOP
 
Creating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdfCreating a Facebook Clone - Part XX.pdf
Creating a Facebook Clone - Part XX.pdf
 
C++ via C#
C++ via C#C++ via C#
C++ via C#
 
C++ Programming - 9th Study
C++ Programming - 9th StudyC++ Programming - 9th Study
C++ Programming - 9th Study
 
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
 
OOP Lab Report.docx
OOP Lab Report.docxOOP Lab Report.docx
OOP Lab Report.docx
 
Test Engine
Test EngineTest Engine
Test Engine
 
Static Analysis in IDEA
Static Analysis in IDEAStatic Analysis in IDEA
Static Analysis in IDEA
 

More from aplolomedicalstoremr

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdf
aplolomedicalstoremr
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
aplolomedicalstoremr
 
This is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdfThis is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdf
aplolomedicalstoremr
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdf
aplolomedicalstoremr
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
aplolomedicalstoremr
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
aplolomedicalstoremr
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
aplolomedicalstoremr
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
aplolomedicalstoremr
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
aplolomedicalstoremr
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
aplolomedicalstoremr
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
aplolomedicalstoremr
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
aplolomedicalstoremr
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
aplolomedicalstoremr
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
aplolomedicalstoremr
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
aplolomedicalstoremr
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
aplolomedicalstoremr
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
aplolomedicalstoremr
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
aplolomedicalstoremr
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
aplolomedicalstoremr
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdf
aplolomedicalstoremr
 

More from aplolomedicalstoremr (20)

You have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdfYou have to leave solids and liquids out of the equation. This lea.pdf
You have to leave solids and liquids out of the equation. This lea.pdf
 
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdfTungsten is a body centered cubic latticeSolutionTungsten is a.pdf
Tungsten is a body centered cubic latticeSolutionTungsten is a.pdf
 
This is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdfThis is the final code which meets your requirement.Than youCard.j.pdf
This is the final code which meets your requirement.Than youCard.j.pdf
 
Statistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdfStatistics is the mathematical science involving the collection, ana.pdf
Statistics is the mathematical science involving the collection, ana.pdf
 
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdfSecondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
Secondary phloemApples (Malus communis, M. pumila, & M. sylvestr.pdf
 
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdfprobability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
probability that the trajectory falls between 1.2 and 1.4 =(1.4-1.2).pdf
 
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdfOutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
OutputFibonacci till 20 0 1 1 2 3 5 8 13 21 .pdf
 
Matter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdfMatter is made up of electrically charge particle but the Constituen.pdf
Matter is made up of electrically charge particle but the Constituen.pdf
 
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdfit is a polynomial of degree 3Solutionit is a polynomial of de.pdf
it is a polynomial of degree 3Solutionit is a polynomial of de.pdf
 
JUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdfJUnit is a Regression Testing Framework used by developers to implem.pdf
JUnit is a Regression Testing Framework used by developers to implem.pdf
 
Intitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdfIntitially take a graph sheet and plot the points and the whole figu.pdf
Intitially take a graph sheet and plot the points and the whole figu.pdf
 
Incapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdfIncapsula Enterprise is the best mitigation service provider with th.pdf
Incapsula Enterprise is the best mitigation service provider with th.pdf
 
Go with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdfGo with the most obvious one first...Carboxylic Acids will have a.pdf
Go with the most obvious one first...Carboxylic Acids will have a.pdf
 
Flexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdfFlexible benefit plans gives employees a choice between qualified be.pdf
Flexible benefit plans gives employees a choice between qualified be.pdf
 
f(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdff(x) = cos(x)Solutionf(x) = cos(x).pdf
f(x) = cos(x)Solutionf(x) = cos(x).pdf
 
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdfEnvironmentLet assume the environment is a grid of colored tiles(.pdf
EnvironmentLet assume the environment is a grid of colored tiles(.pdf
 
Classification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdfClassification of organisms is based upon a number of physical and p.pdf
Classification of organisms is based upon a number of physical and p.pdf
 
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdfAssets=Liabilities+Paid in capital+Retained earnings1..pdf
Assets=Liabilities+Paid in capital+Retained earnings1..pdf
 
Hypothesis Test for population variance If we have a sample fro.pdf
 Hypothesis Test for population variance If we have a sample fro.pdf Hypothesis Test for population variance If we have a sample fro.pdf
Hypothesis Test for population variance If we have a sample fro.pdf
 
ANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.pdfANSWERFundamental configurations of Windows printer Deployments.pdf
ANSWERFundamental configurations of Windows printer Deployments.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
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
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
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 

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
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
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
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 

Polygon .java package chegg2;public class Polygon { Var.pdf

  • 1. Polygon .java package chegg2; public class Polygon { // Variables private int numSides; private double sideLength; private double xCord; private double yCord; // Default Constructor public Polygon () { numSides = 3; sideLength = 5.0; xCord = 0.0; yCord = 0.0; } // Constructor public Polygon (int pSides, double numLength, double numXCord, double numYCord) { numSides = pSides; sideLength = numLength; xCord = numXCord; yCord = numYCord; } // Setter public void setSides(int mSides) { numSides = mSides;
  • 2. System.out.println("setSides() results: "+this.numSides); } // Getter public int getSides() { return numSides; } } TestPolygon .java package chegg2; import java.util.Scanner; public class TestPolygon { public static void main(String[] args) { Polygon poly[] = new Polygon[2]; Polygon poly2 = new Polygon(); poly[0] = poly2; Scanner input = new Scanner(System.in); for(int i=1; i<2; i++){ Polygon obj = new Polygon(); System.out.println("New Polygons"); System.out.println("--------------------------------------------------"); System.out.print("Enter Number of Sides:"); obj.setSides(input.nextInt()); poly[i] = obj; } input.close(); System.out.println("Polygons");
  • 3. System.out.println("--------------------------------------------------"); for(int i=0; i<2; i++) { poly[i].setSides(poly[i].getSides()); } } } Output: run: New Polygons -------------------------------------------------- Enter Number of Sides:9 setSides() results: 9 Polygons -------------------------------------------------- setSides() results: 3 setSides() results: 9 BUILD SUCCESSFUL (total time: 1 second) Solution Polygon .java package chegg2; public class Polygon { // Variables private int numSides; private double sideLength; private double xCord; private double yCord; // Default Constructor public Polygon () {
  • 4. numSides = 3; sideLength = 5.0; xCord = 0.0; yCord = 0.0; } // Constructor public Polygon (int pSides, double numLength, double numXCord, double numYCord) { numSides = pSides; sideLength = numLength; xCord = numXCord; yCord = numYCord; } // Setter public void setSides(int mSides) { numSides = mSides; System.out.println("setSides() results: "+this.numSides); } // Getter public int getSides() { return numSides; } } TestPolygon .java package chegg2; import java.util.Scanner; public class TestPolygon { public static void main(String[] args) { Polygon poly[] = new Polygon[2];
  • 5. Polygon poly2 = new Polygon(); poly[0] = poly2; Scanner input = new Scanner(System.in); for(int i=1; i<2; i++){ Polygon obj = new Polygon(); System.out.println("New Polygons"); System.out.println("--------------------------------------------------"); System.out.print("Enter Number of Sides:"); obj.setSides(input.nextInt()); poly[i] = obj; } input.close(); System.out.println("Polygons"); System.out.println("--------------------------------------------------"); for(int i=0; i<2; i++) { poly[i].setSides(poly[i].getSides()); } } } Output: run: New Polygons -------------------------------------------------- Enter Number of Sides:9 setSides() results: 9 Polygons