C++ program that will allow the creation and handling of hourglasses based on description provided.
Get Help With a similar task to - C++ program that will allow the creation and handling of hourglasses based on description provided.
Programming Assignment #1 Due: Tues, Jan 26 (11:59 PM) Objective: Upon completing this assignment, you should be able to implement a simple class, as well as gain a better understanding of the building and use of classes and objects. Task: An equilateral triangle is a triangle whose sides are equal. If two equliateral triangles are "glued" together along their points (one upside down and one right- side-up), this will form an hourglass. You are to write a class called Hourglass, using filenames hourglass.h and hourglass.cpp, that will allow the creation and handling of hourglasses based on the above description, whose sides are integers in the range 1-39. Details: 1. The single constructor for the Hourglass 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. The border and fill characters must also be in the range described in the SetBorder and SetFill functions below. (If the request is out of bounds, set to the appropriate default). 2. There should be member functions GetSize, Perimeter, and Area, which will return the size of a side, the perimeter of the hourglass, and the area of the hourglass, 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 Hourglass'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. There is a chart of ASCII characters in an appendix of the textbook. 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 Hourglass 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 hourglass). Use the border character to draw the border of the hourglass, 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 Hourglass look more proportional (so that the halves look more like equilateral triangles). You may not use formatting functions like setw to draw the hourglass. This must be handled with loops. (You will only print out the newline, 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 an hourglass: 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 Hourglass and illustrates the usage of the member functions. You can get the driver.cpp file at this link, or you can copy it from your CS account with the unix cp command: ( cp ~myers/c++prog/hw1/driver.cpp . ). I have also provided the output from the sample execution of my driver.cpp program at this link. Your class declaration and definition files must work with my main program, as-is (do not change my program to make your code work!). You are encouraged to write your own driver routines to further test the functionality of your class, as well. Most questions 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 -- not just satisfy this driver program. (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 Requirements No global variables, other than constants! All member data of your class must be private Use the const qualifier on member functions wherever it is appropriate. -- failure to do this will likely cause compiler errors with my test programs You will need to use the <iostream> library for output. You may use the <iomanip> 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 hourglass. You may use the <cmath> library Do not use langauge or library features that are C++11-only When you write source code, it should be readable and well-documented. Here are some general notes on style guidelines Your hourglass.h file should contain the class declaration only. The hourglass.cpp file should contain the member function definitions. Submitting: Program submissions should be done through the submission web page, which will be linked from the main course web site when it is set up. More instructions here will be posted -- TBA -- once the page is set up. General Advice - e-mail a copy of your finished homework files to your own FSU account. This e-mail will have a time stamp that shows when they were sent (i.e. before the due date would be the best idea) , and they will also serve as a backup. It's not a bad idea to keep a copy on your CS account (as well as on a personal computer) -- backing up your work is a GOOD thing! For HW #1, submit the following files hourglass.h hourglass.cpp Make sure your filenames are these exact names, and do not submit the driver.cpp file (or any other main program you might create for testing purposes).
Tutlance Experts offer help in a wide range of topics. Here are some of our top services:
- Math homework help
- Nursing homework help
- Statistics homework help
- Nursing coursework help
- Capstone project writing services
- Essay writers for hire
- Case study writing help
- Buy college papers online
- Buy college research papers
- College homework help
- Professional resume writing services
- Programming homework help
- Coursework writing help
- Term paper writing help
- Biology homework help
- Do my physics homework
- Dissertation data analysis help
- PhD Dissertation writing services
- Chemistry homework help
Post your project now for free and watch professional experts outbid each other in just a few minutes.