Skip to content

Instantly share code, notes, and snippets.

@benfb
benfb / BBaileyBookRunner.java
Created October 2, 2012 15:08
BBaileyBookRunner
public class BBaileyBookRunner
{
public static void main(String args[])
{
BBaileyBook textBook = new Book(); //creates a new object textbook of class Book
textBook.setName("Scooby Doo"); //sets the name of textBook to "Scooby Doo"
textBook.getName(); //println would print default values if the default constructor was called. In this case, the output matches the input
System.out.println(textBook); //What does this line do? It calls the .toString() method
BBaileyBook theStranger = new Book("The Stranger", 123456789); //creates a new book with title "The Stranger" and ISBN 123...
System.out.println(textBook.getName); //prints textBook's name
@benfb
benfb / BBaileyBook.java
Created October 2, 2012 15:05
BBaileyBook
public class BBaileyBook //the name of the class should be "Book"
{
private String bookName; //the variables need to be private because they are instance variables
private int bookISBN; //you don't need to assign default values because they are assigned in the constructors
public BBaileyBook(){ //default constructor named book that should provide default values ("" and 0, respectively) for the instance variables
bookName = ""; //when no arguments are passed, the title defaults to ""
bookISBN = 0; //when no arguments are passed, the ISBN defaults to 0
}
public BBaileyBook(String name, int isbn){ //creates a book object and assigns the name and isbn arguments to the instance variables
@benfb
benfb / BBaileyInvoke.java
Created September 23, 2012 20:51
Invoke
// name:
// purpose: demonstrate further method prowess
public class BBaileyInvoke
{
// method piggyBank(): returns what the change is worth in cents
public static int piggyBank(int pennies, int nickles, int dimes, int quarters, int halfDollars) //creates the piggyBank method, which takes the arguments pennies, nickles, dimes, quarters, and halfDollars
{
double money = (pennies *.01) + (nickles*.05) + (dimes*.1) + (quarters*.25) + (halfDollars*.5); //calculates the amount of money needed
@benfb
benfb / TurtleRunner.java
Last active October 10, 2015 22:38
TurtleRunner
public class TurtleRunner
{
public static void main(String args[])
{
//create a world for your turtles
World turtleWorld = new World(600,800); //creates the turtle canvas
//create a picture
Picture turtle = new Picture("images.jpg"); //lets java know where the picture is
@benfb
benfb / Turtle.java
Last active October 10, 2015 22:38
turtles
import java.util.*;
import java.awt.*;
import java.io.*;
/**
* Class that represents a turtle which is similar to a Logo turtle.
* This class inherts from SimpleTurtle and is for students
* to add methods to.
*
* Copyright Georgia Institute of Technology 2004
@benfb
benfb / BBaileyDateable.java
Last active October 10, 2015 11:58
i/o and variables
// name:
// purpose: determine minimum age of a possible date
import java.util.Scanner; // imports the "Scanner" library, which allows the program to set up a new Scanner object
public class BBaileyDateable
{
// method main(): program starting point
public static void main( String[] args )
{
@benfb
benfb / iAopen.sh
Created August 6, 2011 03:17
iAOpen
#!/bin/bash
open -A /Applications/iA\ Writer.app/ $1
@benfb
benfb / restaurbot.rb
Created August 5, 2011 04:59
A simple restaurant robot
# Restaurbot
$done = false
orders = [
'pizza', 'macaroni'
]
puts 'Hello. What is your name?'
$name = gets.chomp.capitalize
@benfb
benfb / stonednerdkitty
Created April 3, 2011 04:25
The kitty says 'still alive.'
Tonight I decided to set something interesting to happen every time I open the Terminal.
I decided to use cowsay (http://www.nog.net/~tony/warez/cowsay.shtml)
and fortune (http://en.wikipedia.org/wiki/Fortune_(Unix) to have a "cow" (kitten in my case)
give out random quotes from Portal, the Hitchhiker's Guide to the Galaxy and Monty Python and the Holy Grail.
I was successful, and decided to share my method.
First, you should install both programs:
brew install fortune
brew install cowsay