02.21.10

Making a Fractal in Java’s Console

Posted in Java, Programming at 4:32 pm by bryan

From, Data Structures and Other Objects Using Java, Chapter 8, Project #9, page 440:

Examine this pattern of asterisks and blanks and write a recursive method that can generate exactly this pattern:
* 
* * 
  * 
* * * * 
    * 
    * * 
      * 
* * * * * * * * 
        * 
        * * 
          * 
        * * * * 
            * 
            * * 
              * 
With recursive thinking, the method needs only seven or eight lines of ode (including two recursive calls). How is this pattern a fractal? Your method should also be capable of producing larger or smaller patterns of the same variety. Hint: Have two parameters. One parameter indicates the indentation of the leftmost line in the pattern; the other parameter indicates the number of stars in the longest line.

WARNING: Cheating is bad, mmmmkay children? Don’t cheat.

Simulating a Car Wash in Java

Posted in Java, Programming at 4:23 pm by bryan

From, Data Structures and Other Objects Using Java, Chapter 7, Project #8, page 396:

Make improvements to the car was simulation program

from Section 7.2.

Note: Portions of code taken from Michael Main’s version.

WARNING: Cheating is bad, mmmmkay children? Don’t cheat.

Solving the nQueens Problem in Java

Posted in Java, Programming at 4:15 pm by bryan

From Data Structures and Other Objects Using Java, Chapter 6, Project #10, Page #347:

Suppose that you have n queens from a chess game, and that you also have an n-by-n chess board. Is it possible to place all n queens on the board so that no two queens are in the same row, no two queens are in the same column, and no two queens are on the same diagonal?


WARNING: Cheating is bad, mmmmkay children? Don’t cheat.

n Queens source code:

01.20.10

PseudoRandom Number Generation in Java

Posted in Java, Programming at 6:51 pm by bryan

Assignment number 1 in CS211 (Java) programming class. (No stealing! I want full point on my grade!)

PseudoRandomDemo.java


PseudoRandom.java (Class)