Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Programming Language Expert

An equilateral triangle is a triangle whose sides are equal. If two equilateral triangles are "glued" together along a common side, this will form a diamond. You are to prepare a class called Diamond, using filenames diamond.cpp, that will allow the creation and handling of diamonds based on the above description, whose sides are integers in the range 1-39. 
Details:
1. The single constructor for the Diamond class should have 3 parameters: an integer size (required), which is the length of a side; a border character (optional, with a default of '#'); and a fill character (optional, with a default of '*'). If the size provided is less than 
1, set the size to 1. If the size provided is greater than 39, set the size to 39. The class will need to provide internal storage for any member data that must be kept track of. 
2. There should be member functions GetSize, Perimeter, and Area, which will return the size of a side, the perimeter of the diamond, and the area of the diamond, respectively. 
The first 2 should return integer results. The Area function should return its result as a double. 
3. There should be member functions Grow and Shrink, which will increase or decrease (respectively) the size of the Diamond's sides by 1, unless this would cause the size to go out of bounds (out of the 1-39 range); in the latter case, Grow and Shrink should make no 
change to the size. 
4. There should be member functions SetBorder and SetFill, which each allow a new border or fill character (respectively) to be passed in as a parameter. The characters that should be allowed for the border or fill characters are any characters from the '!' (ascii 
33) up through the '~' (ascii 126). If an attempt is made to set the border or fill characters to anything outisde the allowable range, the function should set the border or fill back to its original default (the ones listed for the constructor -- the border default is 
'#' and the fill default is '*'). 
5. There should be a member function called Draw that will display a picture of the Diamond on the screen. You may assume that the cursor is already at the beginning of a line when the function begins, and you should make sure that you leave the cursor on the
line following the picture afterwards (i.e. print a newline after the last line of the diamond). Use the border character to draw the border of the diamond, and use the fill character to draw the internal characters. Separate the characters on a line in the picture 
by a single space to make the Diamond look more proportional (so that the halves look more like equilateral triangles). You may not use formatting functions like setw to draw the diamond. This must be handled with loops. (You will only print out the newline, -2-
spaces, the border character, and maybe the fill character on any given line). 
6. Provide a member function called Summary that displays all information about a diamond: 
its size, perimeter, area, and a picture of what it looks like. When displaying the area (decimal data), always show exactly 2 decimal places. Your output should be in the exact same format as mine (seen in the linked sample run below) 
7. I am providing a sample driver program (called driver.cpp) that uses objects of type 
Diamond and illustrates the usage of the member functions at page 3 of this document. 
I have also provided the output from the sample execution of my driver.cpp program at page 4. Your class declaration and definition files must work with my main program, asis (do not change my program to make your code work!). You are encouraged to prepare 
your own driver routines to further test the functionality of your class, as well. Most problems about the required behavior of the class can be determined by carefully examining my driver program and the sample execution. Keep in mind, this is just a sample. Your class must meet the specified requirements listed above in the specification. (For instance, I haven't tested every illegal fill character in this driver program -- I've just shown a sample). Your class will be tested with a larger set of calls than this driver program represents. 
8. General Requirementso No global variables, other than constants!
o All member data of your class must be private
o You will need to use the library for output. You may use the  library for formatting your decimal output to two places, if you wish to use the parameterized stream manipulators, but you may not use setw() or other output formatting functions for drawing the actual diamond. You may use the library
o When you prepare source code, it should be readable and well-documented.
o The diamond.cpp file should contain the class declaration and the member function definitions 

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M9111035

Have any Question?


Related Questions in Programming Language

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Overviewthis tasks provides you an opportunity to get

Overview This tasks provides you an opportunity to get feedback on your Learning Summary Report. The Learning Summary Report outlines how the work you have completed demonstrates that you have met all of the unit's learn ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Background informationthis assignment tests your

Background Information This assignment tests your understanding of and ability to apply the programming concepts we have covered throughout the unit. The concepts covered in the second half of the unit build upon the fun ...

Php amp session managment assignment -this assignment looks

PHP & SESSION MANAGMENT ASSIGNMENT - This assignment looks at using PHP for creating cookies and session management. Class Exercise - Web Project: Member Registration/Login This exercise will cover adding data connectivi ...

Task - hand execution of arraysoverviewin this task you

Task - Hand Execution of Arrays Overview In this task you will demonstrate how arrays work by hand executing a number of small code snippets. Instructions Watch the Hand Execution with Arrays video, this shows how to ste ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As