1 / 8

Lecture 9: The Programming Process

Lecture 9: The Programming Process. Yoni Fridman 7/11/01. Outline. Designing a program Step 1: Understanding the problem Let’s try this step for a realistic poker game Step 2: Building the foundation Let’s try this step Step 3: Filling in the details Let’s try this step

nairi
Télécharger la présentation

Lecture 9: The Programming Process

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lecture 9: The Programming Process Yoni Fridman 7/11/01

  2. Outline • Designing a program • Step 1: Understanding the problem • Let’s try this step for a realistic poker game • Step 2: Building the foundation • Let’s try this step • Step 3: Filling in the details • Let’s try this step • Step 4: Writing code

  3. Designing a Program • So far, we’ve worked with short, simple programs. • For such programs it’s fine to sit in front of the computer and start typing code. • More significant programs can’t be done like this – they must be carefully designed first.

  4. 1: Understanding the Problem • First, we must understand the problem – what exactly is our program supposed to accomplish? • For example, assume we are told to write a program that plays a realistic game of poker. • What are the specifications for our program? • How many players should there be? • What style of poker should it play? • What are all the rules that our program should follow? • Let’s write a set of specifications for a poker game.

  5. 2: Building the Foundation • Once we have clear specifications, the next step is to “outline” our program. • For example, the outline for our simple Black Jack game of HW3 might look as follows: • Initialize hands • Initialize player’s hand • Initialize dealer’s hand • Do player’s turn … • Do dealer’s turn … • Figure out who won … • Let’s outline our poker game.

  6. 3: Filling in the Details • After our program outline is written, we can fill in the details. • We do this by writing pseudocode. Pseudocode is text that’s formatted like a program, but written in English. • Example: Initialize player’s total to zero. Initialize dealer’s total to zero. While player keeps hitting … Deal the player a new card. Add the new card’s value to the player’s total. … • Let’s write our poker game in pseudocode.

  7. 4: Writing Code • If your pseudocode is good enough, you can almost translate each line of pseudocode into a Java statement. • This will be your next programming assignment. • Note: Make sure you follow the style sheet’s guidelines on future homeworks.

  8. Homework • HW4: Review questions, due tomorrow. Write up at least three questions to turn in on anything through Lecture 6: For Loops.

More Related