194k views
0 votes
write a method that takes a regularpolygon as a parameter, and changes the number of sides so it becomes an equilateral triangle (i.e. set the number of sides to 3). this method must be called makeeqtriangle() and it must take a regularpolygon as a parameter. you can call your method in the program's main method so you can test whether it works, but you must remove or comment out the main method before checking your code for a score. for example, if the following code appeared in your main method: regularpolygon poly

1 Answer

0 votes

Final answer:

The method makeeqtriangle() changes a RegularPolygon object to have 3 sides, turning it into an equilateral triangle. The method should use the setNumberOfSides() method of the RegularPolygon class.

Step-by-step explanation:

The student is asking how to write a method called makeeqtriangle() that converts any regular polygon into an equilateral triangle by setting its number of sides to 3. This method should accept an object of type RegularPolygon as a parameter. Assuming we are working within an object-oriented programming language like Java, the method could be defined within the RegularPolygon class or as a static method in a utility class.

Here is a potential implementation of the method:


public void makeeqtriangle(RegularPolygon poly) {
poly.setNumberOfSides(3);
}

When called, this method will take a RegularPolygon object and use a hypothetical setNumberOfSides method to change the number of sides to 3. To test the method, it could be called from the main method, which should be commented out before submission if required.

User Pranay Soni
by
9.1k points