Homework2

# Homework2 - CS 130 Homework 2 2.1 Kevin Deggelman May 4...

This preview shows pages 1–4. Sign up to view the full content.

CS 130 Kevin Deggelman May 4, 2009 Homework 2 2.1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
2.2 2.3 /* Part 1 The design pattern used to solve this problem is a recursive program that has inputs of the representation of the board, and whose turn it is. The program makes all possible moves at each step, and keeps track of the percentage of time that move leads to a victory. */ class BoardRepresentation { } class Player { boolean isTurn ; void setTurn( boolean bool) {
isTurn = bool; } } int makeMove(BoardRepresentation theBoard, Player player1, Player player2 ) { int winPercentage; //Choose a move, update the board, and call make move BoardRepresentation newBoard; if (player1. isTurn == true ) { player1.setTurn( false ); player2.setTurn( true ); } else { player1.setTurn( true ); player2.setTurn( false ); } return winPercentage + makeMove(newBoard, player1, player2); } /* Part 2 To solve this problem, we will use inheritance to give special properties to notes, melodies, verses, and songs. We need to create a Melody from 2 or more Notes.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

Homework2 - CS 130 Homework 2 2.1 Kevin Deggelman May 4...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online