Skip to content

Instantly share code, notes, and snippets.

@tatey
tatey / Account.java
Created August 13, 2008 04:13
Solution to Lab 3 for 1005ICT
/**
* Write a description of class Account here.
*
* @author Tate Johnson
* @version 2008-08-07
*/
public class Account {
@tatey
tatey / AccountTester.java
Created August 13, 2008 04:14
Solution to Lab 3 test class for 1005ICT
/**
* Write a description of class AccountTester here.
*
* @author Tate Johnson
* @version 2008-07-08
*/
public class AccountTester {
@tatey
tatey / Lab5.java
Created August 27, 2008 02:20
Solution to Lab 5 for 1005ICT
/**
* @author Tate Johnson
* @version 2008-08-20
*/
public class Lab5 {
// Instance variable
private double[] data;
@tatey
tatey / GameBoard.java
Created September 2, 2008 09:17
Solution to Lab 7 for 1005ICT
import java.util.Random;
/**
* Class GameBoard for Lab7
*
* @author Tate Johnson
* @version 2008-09-02
*/
public class GameBoard {
@tatey
tatey / GameBoard.rb
Created September 3, 2008 10:14
Solution to Lab 7 for 1005ICT in Ruby
# Ruby implementation of Lab 7 for 1005ICT (Java Programming) at Griffith Univeristy.
# Why? To practice learning Ruby
class GameBoard
attr_accessor :board
def initialize(row, col)
@board = Array.new(row) { |row| Array.new(col, 0) }
end
def get_response_from_remote(url, retry_count, timeout_in_seconds)
begin
url = URI.parse(url)
timeout(timeout_in_seconds) do
Net::HTTP.start(url.host) do |session|
if url.query
response = session.get(url.path + "?" + url.query)
else
response = session.get(url.path)
end
require "ftools"
require "net/http"
require "rexml/document"
require "timeout"
require "uri"
# Methods for retrieving social data from services including Flickr, Last.fm and Twitter.
module SocialServices
def get_recently_uploaded_from_flickr(limit)
recently_uploaded = []
/**
* Charges annual fee on all accounts if an annual fee is applicable. Returns
* total amount of revenue collected by summing the rates of all annual fees charged
*
* @return Sum of annual fees charged
*/
public int chargeAnnualFees()
{
int totalAnnualFees = 0;
for (Account account : accounts)
# Now playing script for Irssi which retrieves your currently listened to song from the Last.fm API
#
# 1) Define your last.fm username and api account key
# 2) Load script in to Irssi "/script load lastfm" (Assuming you've placed the script in .irssi/scripts)
# 3) Execute script from witin Irssi "/np"
my $user = "<USERNAME>";
my $api_key = "<API_KEY>";
##### DO NOT EDIT BELOW THIS LINE #####
// Enhanced for loop (For each)
public int sum(int[] nums)
{
int sum = 0;
for (int num : nums)
{
sum += num * num
}
return sum;
}