Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 8 Basic Design and Documentation. Learn about top-down design and how to document your code properly. Look at a design diagram to figure out how to.

Similar presentations


Presentation on theme: "Lab 8 Basic Design and Documentation. Learn about top-down design and how to document your code properly. Look at a design diagram to figure out how to."— Presentation transcript:

1 Lab 8 Basic Design and Documentation

2 Learn about top-down design and how to document your code properly. Look at a design diagram to figure out how to break a large problem down into manageable sub-problems. Be able to program incrementally. Goals

3 Change into the lab8 folder in your cs201/labs directory and create a lab8.py cd 201/labs cd lab8 emacs lab8.py & Step 0: Setup

4 Create a program which simulates a vending machine. Inventory: –Pepsi- Tortilla Chips- Mint Gum –Sprite- Knives- Bubble Gum –KoolAid- Forks- Doritos All inventory start at 5 items each. Program Objectives

5 Design Diagram

6 Write top-level functions These are functions that are easy to take care of without testing –printGreeting() –getValidInt () On next slide –Write stubs for other necessary functions Step 1

7 def getValidInt(question, min, max): # use a bad value to enter the loop value = max + 1 # compose the prompt prompt = question + " (" + str(min) + "-" + str(max) + "): " # continue to get values until the user enters a valid one while value == "" or value max: value = input(prompt) if len(value) != 0: value = int(value) # return a valid value return value getValidInt() # Filename: getValidInt.py # Author: Sue Evans # Date: 8/9/09 # Section: All # Email: bogar@cs.umbc.edu # Description: This program illustrates use of a while # loop to get values from the user within # a specified range, rejecting all bad input. # The function uses a post-test loop.

8 Go through the design diagram and determine the required functions along with the function parameters. Since each function is separate, independent testing can be (and should be) preformed before integrating it into the main program. Not all functions need to be complete to be able to run lab8.py –You accomplish this via a function stub. –At the end of the function, return nothing. Filling in the Other Functions

9 201 coding standards must be present for full credit. # findCircleArea() calculates the area of a circle with the # radius passed in # Input: the circle's radius # Output: the circle's area findCircleArea(): return Documentation: Function Headers

10 Fill in the other functions to make the rest of the vending machine to work appropriately. Correctly document your code with function headers and inline comments Lab completion will be based on how well designed your code is, not how complete it is Completing the lab


Download ppt "Lab 8 Basic Design and Documentation. Learn about top-down design and how to document your code properly. Look at a design diagram to figure out how to."

Similar presentations


Ads by Google