SlideShare una empresa de Scribd logo
1 de 13
The “Simple Dot Com Game” Goal: Sink all of the computer’s Dot Coms in the fewest number of guesses. You’re given a taring of level, based on how well you perform. Setup: When the game program is launched, the computer places three Dot Coms on a virtual 7x7 grid. When that’s complete, the game asks for your first guess. How you play: The computer will prompt the user to enter a guess. In response to the guess you’ll see a response at the command line: “Hit”, “Miss”, or “You sunk Pets.com” (or whatever the name of the company was). When all companies are sunk the game ends by reporting your rating. LIS4930 © PIC
A High-Level Design	 See you textbooks on page 97. LIS4930 © PIC
The Three Things! LIS4930 © PIC PREP CODE TEST CODE REAL CODE Prep code: A form of pseudocode, to help you focus on the logic without stressing about syntax. Test code: A class or methods that will test the real code and validate that it’s doing that right thing. Real code: The actual implementation of the class. This is where you put the real Java code.
Prep Code Most prepcode includes three parts:  Instance variable declarations Method declarations Method logic LIS4930 © PIC PREP CODE SimpleDotCom int[] locationCells intnumOfHits String checkYourself(String guess) void setLocationCells(int[] loc) Let’s give it a try!
Test Code LIS4930 © PIC TEST CODE The concept of writing the test code first is one of the practices of Extreme Programming (XP), and it can make it easier (and faster) for you to write your code. Based on our prep code what should we test?
Test Code for the SimpleDotCom Class LIS4930 © PIC TEST CODE
The checkYourself() Method LIS4930 © PIC REAL CODE
Final code for SimpleDotCom and SimpleDotComTestDrive LIS4930 © PIC
Let’s Finish Our SimpleDotComGame Class LIS4930 © PIC Check out the prep code on page 108. Check out the main() method on page 110. Let’s Play!
More about for loops! LIS4930 © PIC for (inti = 0; i < 100; i++) {  } Part One: initialization Part Two: boolean test Part Three: iteration expression Take a trip through a for() loop on page 115.
Difference Between While and For LIS4930 © PIC The whileloop has only the Boolean test; it doesn’t have a built-in initialization or iteration expression.A whileloop is good when you don’t know how many times to loop and just want to keep going while some condition is true. But, if you knowhow many times to loop a forloop is cleaner. Let’s compare the two types of loops.
The Enhanced For Loop! LIS4930 © PIC for (String name : nameArray) {  } Part One: initialization variable declaration Part Two: the actual collection Let’s look at an example!
Casting Primitives LIS4930 © PIC I have already gone over this concept in class, but read page 117 in your textbook for a more in-depth explanation.  long byte can be cast to

Más contenido relacionado

Similar a 06b extra methods

Game programming workshop
Game programming workshopGame programming workshop
Game programming workshopnarigadu
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to UnityKoderunners
 
DVR Networking: How to Connect Your DVR to the LAN
DVR Networking: How to Connect Your DVR to the LANDVR Networking: How to Connect Your DVR to the LAN
DVR Networking: How to Connect Your DVR to the LANChristian Watson
 
Chapt 6 game testing and publishing
Chapt 6   game testing and publishingChapt 6   game testing and publishing
Chapt 6 game testing and publishingMuhd Basheer
 
My summary for cs001x computer science for beginners
My summary for cs001x computer science for beginnersMy summary for cs001x computer science for beginners
My summary for cs001x computer science for beginnersIbrahim Omar
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10stemplar
 
Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedSvetlin Nakov
 
arduino
arduinoarduino
arduinomurbz
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeypprem
 
GUIDE TO PROGRAMMING WITH PYTHON
GUIDE TO PROGRAMMING WITH PYTHONGUIDE TO PROGRAMMING WITH PYTHON
GUIDE TO PROGRAMMING WITH PYTHONLebogang Modise
 
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesHow to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesChristian Beedgen
 
An introduction to coding
An introduction to codingAn introduction to coding
An introduction to codingiain bruce
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsshyaminfo04
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsash52393
 
Authenticated Code Execution by Design.pptx
Authenticated Code Execution by Design.pptxAuthenticated Code Execution by Design.pptx
Authenticated Code Execution by Design.pptxegypt
 
ma project
ma projectma project
ma projectAisu
 

Similar a 06b extra methods (20)

06a methods original
06a methods original06a methods original
06a methods original
 
Game programming workshop
Game programming workshopGame programming workshop
Game programming workshop
 
Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
 
Python in details
Python in detailsPython in details
Python in details
 
DVR Networking: How to Connect Your DVR to the LAN
DVR Networking: How to Connect Your DVR to the LANDVR Networking: How to Connect Your DVR to the LAN
DVR Networking: How to Connect Your DVR to the LAN
 
Chapt 6 game testing and publishing
Chapt 6   game testing and publishingChapt 6   game testing and publishing
Chapt 6 game testing and publishing
 
My summary for cs001x computer science for beginners
My summary for cs001x computer science for beginnersMy summary for cs001x computer science for beginners
My summary for cs001x computer science for beginners
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Java Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting StartedJava Tutorial: Part 1. Getting Started
Java Tutorial: Part 1. Getting Started
 
arduino
arduinoarduino
arduino
 
Easy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkeyEasy coding a multi device game with FireMonkey
Easy coding a multi device game with FireMonkey
 
GUIDE TO PROGRAMMING WITH PYTHON
GUIDE TO PROGRAMMING WITH PYTHONGUIDE TO PROGRAMMING WITH PYTHON
GUIDE TO PROGRAMMING WITH PYTHON
 
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production ServicesHow to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
How to Meta-Sumo - Using Logs for Agile Monitoring of Production Services
 
An introduction to coding
An introduction to codingAn introduction to coding
An introduction to coding
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Devry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and stringsDevry cis 170 c i lab 5 of 7 arrays and strings
Devry cis 170 c i lab 5 of 7 arrays and strings
 
Pic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guidePic microcontroller step by step your complete guide
Pic microcontroller step by step your complete guide
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 
Authenticated Code Execution by Design.pptx
Authenticated Code Execution by Design.pptxAuthenticated Code Execution by Design.pptx
Authenticated Code Execution by Design.pptx
 
ma project
ma projectma project
ma project
 

Más de Program in Interdisciplinary Computing (20)

Phpmysqlcoding
PhpmysqlcodingPhpmysqlcoding
Phpmysqlcoding
 
Database basics
Database basicsDatabase basics
Database basics
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
01 intro tousingjava
01 intro tousingjava01 intro tousingjava
01 intro tousingjava
 
Web architecture v3
Web architecture v3Web architecture v3
Web architecture v3
 
Xhtml
XhtmlXhtml
Xhtml
 
Webdev
WebdevWebdev
Webdev
 
Web architecture
Web architectureWeb architecture
Web architecture
 
Sdlc
SdlcSdlc
Sdlc
 
Mysocial
MysocialMysocial
Mysocial
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Html5
Html5Html5
Html5
 
Frameworks
FrameworksFrameworks
Frameworks
 
Drupal
DrupalDrupal
Drupal
 
Database
DatabaseDatabase
Database
 
Javascript2
Javascript2Javascript2
Javascript2
 

06b extra methods

  • 1. The “Simple Dot Com Game” Goal: Sink all of the computer’s Dot Coms in the fewest number of guesses. You’re given a taring of level, based on how well you perform. Setup: When the game program is launched, the computer places three Dot Coms on a virtual 7x7 grid. When that’s complete, the game asks for your first guess. How you play: The computer will prompt the user to enter a guess. In response to the guess you’ll see a response at the command line: “Hit”, “Miss”, or “You sunk Pets.com” (or whatever the name of the company was). When all companies are sunk the game ends by reporting your rating. LIS4930 © PIC
  • 2. A High-Level Design See you textbooks on page 97. LIS4930 © PIC
  • 3. The Three Things! LIS4930 © PIC PREP CODE TEST CODE REAL CODE Prep code: A form of pseudocode, to help you focus on the logic without stressing about syntax. Test code: A class or methods that will test the real code and validate that it’s doing that right thing. Real code: The actual implementation of the class. This is where you put the real Java code.
  • 4. Prep Code Most prepcode includes three parts: Instance variable declarations Method declarations Method logic LIS4930 © PIC PREP CODE SimpleDotCom int[] locationCells intnumOfHits String checkYourself(String guess) void setLocationCells(int[] loc) Let’s give it a try!
  • 5. Test Code LIS4930 © PIC TEST CODE The concept of writing the test code first is one of the practices of Extreme Programming (XP), and it can make it easier (and faster) for you to write your code. Based on our prep code what should we test?
  • 6. Test Code for the SimpleDotCom Class LIS4930 © PIC TEST CODE
  • 7. The checkYourself() Method LIS4930 © PIC REAL CODE
  • 8. Final code for SimpleDotCom and SimpleDotComTestDrive LIS4930 © PIC
  • 9. Let’s Finish Our SimpleDotComGame Class LIS4930 © PIC Check out the prep code on page 108. Check out the main() method on page 110. Let’s Play!
  • 10. More about for loops! LIS4930 © PIC for (inti = 0; i < 100; i++) { } Part One: initialization Part Two: boolean test Part Three: iteration expression Take a trip through a for() loop on page 115.
  • 11. Difference Between While and For LIS4930 © PIC The whileloop has only the Boolean test; it doesn’t have a built-in initialization or iteration expression.A whileloop is good when you don’t know how many times to loop and just want to keep going while some condition is true. But, if you knowhow many times to loop a forloop is cleaner. Let’s compare the two types of loops.
  • 12. The Enhanced For Loop! LIS4930 © PIC for (String name : nameArray) { } Part One: initialization variable declaration Part Two: the actual collection Let’s look at an example!
  • 13. Casting Primitives LIS4930 © PIC I have already gone over this concept in class, but read page 117 in your textbook for a more in-depth explanation. long byte can be cast to