COMP 248 Study Guide - Quiz Guide: Regular Polygon

384 views1 pages

Document Summary

Due date: today, at the end of the lab period. Question: implement a class named polygon which describes an n-sided polygon where all sides have the same length, and has: A default constructor that creates a regular polygon with 5 sides, each of length 1. 5, with pink as the fill color and blue as the border color. Second constructor with parameters that accepts four values and initializes n, sides, fill and border to these passed values. The accessor (get) and mutator (set) methods for all data fields. Write the driver class to test the program as follows: Create two objects (e. g. obj1, obj2) using two different constructors. The number of sides in the second constructor should be a number greater than 3, if not, assign a default value (e. g. 3) to it. Ask the user to enter a new border color for obj1. The border color should be (cid:862)red(cid:863), or (cid:862)blue(cid:863), or (cid:863)green(cid:863).