CSE/ENGR 142 Homework 4
|
These last few weeks have shown Washington the sun for the first time in quite a while. Washingtonians have been so excited that ice cream sales have shot through the roof, and now the entire state's stock is depleted. Finding a cone is near impossible, so you decide to take matters into your own hands. Using your vast knowledge of computer programming, you've decided to write an ice cream cone builder. Now you can control the creation of ice cream at your will!
In this program you will have several new experiences. You will program in an event-driven style; you will use graphics; you will have to figure out how to use a library of functions (how? by reading the manual, experimenting and looking at examples). You will have to understand and then modify a large and not always pretty program that someone else wrote. Finally, you will get to apply all kinds of new programming knowledge, such as output parameters and arrays.
There are two parts to this assignment with two different due dates.
Part A: Due Monday, July 26 at 5:00 p.m.: a call graph of the original file plus solutions to written exercises.
Part B: Ice Cream Cone Maker program, final version submitted via electronic turn-in by 5:00 p.m. on Friday, July 30. Usual deadline policies apply. There will be an extra-credit opportunity!
This homework uses the GP142 graphics package. Read all about on the Web, or in the course packet. You don't have to memorize this material, but you need to get familiar with it. We will not be spending class or quiz time talking about it!
You have a sample executable program to experiment with. Many of the following instructions won't make sense until you have tried it. Play with it to figure out what it can do. The final version of your program does not have to behave exactly like this.
To start work off, you have a .c file called hw4_orig.c. Your first jobs is to study it, get it to compile, then run it and figure out what it does. [There's an important note below about compiling the program.] You should look at the code; some of it won't make sense right away, and doesn't have to. To help ensure you understand at least the "big picture," make a call graph showing all the functions called in hw4_orig.c. This is due with Part A of the homework along with your solutions to the written exercises. The call graph should include a box for every function which is defined in or called from hw4_orig.c; it doesn't have to include any functions which are not either defined in or called from hw4_orig.c. (For example: it should not include any functions which you plan to write later. It should not include functions which may be defined in GP142.c but which are not called from hw4_orig.c). [Hint: start with a big piece of paper!] Here is an example of a call graph for a program from one of the previous quarters.
Keep a copy of your call graph to refer to as you continue to study the program. As you modify the program, keep the graph updated to reflect your changes. If you are in the IPL and ask a consultant to help you, have that updated copy of the call graph on hand; it will help both of you understand your program.
For Part B of the homework, improve the program so that it is pretty interesting. It should be at least as interesting as the sample executable program. But it doesn't have to do exactly the same things. Here's what it should do at least:
Information about the toppings (such as the color, type, or location of the topping) is stored in arrays. Currently, only 10 toppings are allowed on the cone at once. It usually takes a while to understand programming with the GP142 graphics package, but once you do, it can be lots of fun. Feel free to be creative! You might think of a better way to accomplish the same purposes as the demo. If you have no creative ideas of your own, you can just copy what the demo does and get full credit for that.
Caution: Be realistic and don't try to do too much all at once. It is much more important to have something fairly simple that works instead of something overly complex that you can't finish in time. Start with a simplified version of your ultimate program, get that working, and then add to it.
For a small amount of extra credit, make your program so interesting that the TA is forced to exclaim, "Wow! This is incredible. Hey, everybody, come and take a look at what this program does!" You do not have to use fancy features of C. The extra-credit judgement will be based on what the program does, not on how it does it. It will only be a couple of extra points at most. The most imaginative programs will be nominated for a Hall of Fame and demonstrated in lecture.
As time passes, we may put out a number of hints and guidelines as to how to achieve various effects, so check the HW4 announcements page occasionally.
If you are using Windows, we strongly advise that you compile and modify the program ONLY via the .dsw file that will be supplied in the self-extracting archive. Here's why. GP142 programs differ from previous projects in some important ways. First, they have multiple .c files (gp142.c in addition to your own). Second, they use a special .h file that must be available to the compiler. Third, they are built as "Windows Applications" rather than "Console Applications." All of this means that you cannot create a "default project workspace" to compile and run your program in. If you click on the .dsw file we give you (.dsp for users of older versions of MSVC), all this is taken care of.
If you really need to know how to create your own project, look at the tips on-line.