Skip to content

Lewis-Matt/dot-com-killer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 

Repository files navigation

dot-com-killer


Think Battleship™, only we are sinking tech startups like it is 2001.

This is an exercise from Head First Java™ (HIGHLY recommend for any wannabe Java Jabronis [like myself]) chapters 5 and 6.

The Jist

The computer is attempting to start a bunch of dot-com business's. As a corporate take-over VP, it is your job to sink as many of their startups in the fewest number of tries (how else would we maintain our Monopoly status?). You will be rated based on your performance, and PIP'd (i.e. sacked) if you don't perform!

The computer will place 3 dot-coms on a 7x7 grid (no GUI, this is a command-line application).

Note that the first iteration of the game (SimpleDotCom) is just a single row of 7 cells and one dot-com that takes up 3 cells.

This iteration exists to show:
     1. Arrays suck and you should use ArrayList
     2. To start simple, get it working (pass tests) and scale up to meet requirements
     3. How/when to refactor

Use


Run the simple version or the robust version:

  1. java SimpleDotCom
    1. enter a number 0-6
    2. keep entering until you sink the dot-com (3 hits)
  2. java DotComBust
    1. enter a cell [a-f][0-6]
    2. 3 hits(cells) per dot-com, 3 dot-coms total
      1. example input: a3, d6, etc.

Design Process


High-Level

  1. User starts the game
    1. Game creates 3 objects (dot-coms)
    2. Game places 3 objects into 7x7 grid (randomly)
  2. Game play begins, repeat:
    1. Prompt user for guess
    2. Check the user guess - look for hit/miss/kill
      1. if a hit, delete the cell
      2. if a kill, delete the dot-com object
  3. Game finishes
    1. Give the user a rating based on number of guesses

Developing a Class

  • What is the Class supposed to do?

  • List instance variables and methods

  • Prepcode (pseudo)

  • Test code **

  • Implement the Class

  • Test the methods

  • Debug/reimplement

    ** Writing test code first comes from XP. At the time you write the code, there is nothing to run it against. The act of thinking through and writing test code helps clarify your thoughts about what the method itself needs to do. As soon as the implementation code is done, you already have test code ready to validate it.

    Besides, if you don't do it first, you'll never do it (proven scientific fact)!

About

Think Battleship™, only we are sinking tech startups like it is 2001.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages