Skip to content

Instantly share code, notes, and snippets.

View christopherturner's full-sized avatar

Christopher Turner christopherturner

View GitHub Profile
@christopherturner
christopherturner / keybase.md
Created June 16, 2016 08:40
Authenticating my Keybase.io

Keybase proof

I hereby claim:

  • I am christopherturner on github.
  • I am cmt (https://keybase.io/cmt) on keybase.
  • I have a public key whose fingerprint is 3746 2B06 9578 E303 56B3 D887 C788 604F 98D8 1C0A

To claim this, I am signing this object:

@christopherturner
christopherturner / SearchAlgs.java
Created April 28, 2016 03:24
Intro to Programming - Assignment 8.1 - Question for Dr. Frewen
// Written by Christopher Turner.
import java.util.*;
public class SearchAlgs {
public static int getMin(int[] a) { //Finds the minimum value in an array of integers
int min = 0; //Initializes to 0
for (int i : a) { //For every item in the array...
if (i < min) { //If the minimum variable is greater than the current element
min = i; //Set the minimum variable equal to the current element
@christopherturner
christopherturner / NthRoot.java
Created January 19, 2016 01:58
Midterm Project - Christopher Turner - Flintridge Preparatory School
import java.util.*; //Imports
public class NthRoot {
public static void main(String[] args) {
Calculator rootFinder = new Calculator(); //Creates a new calculator object from the class (simply for modularizing my code)
double radical = (double) rootFinder.getRadical(); //Gets the number x that you want to find the nth root of
int n = rootFinder.getN(); //Gets the number n to find the nth root of "radical"
int requestedError = rootFinder.getRequestedError(); //Gets the integer P to find the error tolerated in the form 10E-P
double xtoN = radical; //Creates a variable for the final result, initially setting it equal to the input
double calculatedError = Math.pow(10, -(requestedError)); //Inserts the requestedError as the exponent P in 10E-P, to calculate the threshold where an answer over is wrong but an answer under is correct
while (Math.abs(radical - Math.pow(xtoN,n)) > calculatedError) { //Runs while the difference between the inital input and the
@christopherturner
christopherturner / TempNthRoot.java
Last active January 28, 2016 20:57
Midterm Project - Christopher Turner - Flintridge Preparatory School
// Written by Christopher Turner.-
import java.util.*;
public class NthRoot {
public static void main(String[] args) {
Calculator rootFinder = new Calculator();
double radical = (double) rootFinder.getRadical();
int n = rootFinder.getN();
int requestedError = rootFinder.getRequestedError();
double xtoN = radical; //Creates a variable for the final result, initially setting it equal to the input
double calculatedError = Math.pow(10, -(requestedError)); //Applies the base to the variable exponent to get the maximum allowed degree error
for (Player p: players) {
p.receiveCard(gameDeck.drawCard());
}
@christopherturner
christopherturner / Card.java
Created November 20, 2015 18:30
Card class for Scott Johnson
public class Card {
//Here you need to declare the instance variables for the Card object
private final int suit;
private final int rank;
// Kinds of ranks
public final static int ACE = 1;
public final static int DEUCE = 2;
public final static int THREE = 3;
public final static int FOUR = 4;
public final static int FIVE = 5;
@christopherturner
christopherturner / BattleshipWilliam.md
Last active November 17, 2015 05:01
Notes on Battleship/BattleshipGame for William Pai.
  • numOfHits was previously just an integer variable that would go from 0 to 3 and then you used it to terminate the program when it hit three. Now that you're using an arraylist, I'd recommend instead making your while loop in the BattleshipGame class make use of the size() function. For example: while (myShip.alreadyGuessed.size() < 3) { You'll also need to update other parts of the program that use numOfHits so that the program will work as expected.
  • I'd recommend putting aside bonus problems until after you get the core program working. For now, comment out anything having to do with the bonuses (for example, your variable numOfGuesses and your method getNumOfGuesses() ).
  • It looks like you call the guess that the user made userGuess at one point in the program, while calling it theGuess later on. Make sure you're consistent and only use a single variable for the user's guess.
  • In order to better understand your program, consolidating multiple lines into single ones may help. For exampl