02.21.10
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.
Permalink
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.
Permalink
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:
Permalink
01.20.10
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)
Permalink
11.15.09
Posted in Programming, School, c++ at 9:35 pm by bryan
Finally! I did it! Assignment #4 is complete, and I can manipulate dates pretty effing easily now.
No doubt there is already some vastly superior date manipulation library already out there… stupid school.
Just kidding. I learned a LOT with this assignment.
Permalink
11.05.09
Posted in c++ at 7:15 pm by bryan
This was my version of a C++ assignment to count votes from a text file. It’s not super useful outside the classroom, but I’m posting it anyway.
Permalink
10.07.09
Posted in Programming, School, c++ at 11:51 pm by bryan
One of these days I’ll actually know how to program c++ pretty well, and when that happens, I plan to write some kickass software. But when that happens, I figured it would be pretty amusing to look back at my very first c++ program (besides the mandatory “Hello World!” app).
This was our first assignment in Computer Science 210, page 98, #15 in Problem Solving, Abstraction & Design Using C++ (5th Edition)
. To quote:
Write a program that dispenses change. The program should read the amount of the purchase and the amount paid and then display the number of dollars, quarters, dimes, nickels, and pennies given in change.
Actually if you keep reading, they tell you the wrong way to do it, as a “hint”. Jerks.
But notwithstanding, this is what I wrote:
I promise, there was lots more whitespace in the actual program. Wordpress is just being stupid. Here's the file for download: ChangeDispenser.cpp.
Warning: Don't cheat off me.
UPDATE 10-19-09: Fixed a bug in how pennies were calculated.
UPDATE 11-01-09: Fixed formatting / lack of whitespace.
Permalink