Skip to content

Instantly share code, notes, and snippets.

@snarkbait
snarkbait / TaxCalculator.java
Last active August 29, 2015 14:15
2014 US Federal Tax Calculator
public class TaxCalculator implements TaxLookup
{
public static double getTax(int income, int status)
{
double tax = 0;
for (int i = 0; i < 7; i++)
{
if (income > lookup[status][i][1])
package philyboyd_studge;
public class MinecraftChallenge {
public static void main(String[] args) {
World world = new World();
world.updateWorld();
import java.util.Random;
public class Game21
{
private int[] heap;
private Random rand = new Random();
private boolean computerOpponent;
private boolean lastPlayWins;
@snarkbait
snarkbait / Inventory.java
Last active November 9, 2016 21:29
Sorted Doiubly-Linked List example for /r/javaexamples
public class Inventory implements Comparable<Inventory>
{
private String item;
private int qty;
private float price;
public Inventory(String item, int qty, float price)
{
this.item = item;
this.qty = qty;
@snarkbait
snarkbait / BinaryTreeKV.java
Created May 22, 2015 06:38
Generic Self-Balancing Key-Value Binary Search Tree for /r/javaexamples
/* Generic Self-Balancing Key-Value Binary Search Tree
for /r/javaexamples
by /u/Philboyd_Studge
*/
import java.util.Queue;
import java.util.LinkedList;
import java.util.List;
@SuppressWarnings("unchecked")
@snarkbait
snarkbait / Inventory.java
Last active March 31, 2021 17:11
InventoryGUI SQlite Example for /r/javaexamples
/* Inventory class
* for /r/javaexamples
* by /u/Philboyd_Studge
*
*/
package philboyd.studge;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Random;
@snarkbait
snarkbait / BinaryHeap.java
Last active December 10, 2022 22:45
Generic Min/Max Binary Heap
/* Generic Min/Max Binary Heap
* for /r/javaexamples
*
*/
import java.util.Arrays;
@SuppressWarnings("unchecked")
/**
* Creates an array-based binary heap. Defaults to 'min' (Priority Queue)
@snarkbait
snarkbait / DiGraph.java
Created June 2, 2015 06:10
Generic Directed, Weighted Graph with Dijkstra's Shortest Path
/* Generic Directed Weighted Graph with Dijkstra's Shortest Path Algorithm
* by /u/Philboyd_Studge
* for /r/javaexamples
*/
import java.util.List;
import java.util.Queue;
import java.util.PriorityQueue;
import java.util.Deque;
import java.util.LinkedList;
@snarkbait
snarkbait / MergeSort.java
Last active August 29, 2015 14:23
Top-Down Merge Sort
/*
* Generic Top-Down Merge Sort
* Based on this
* https://en.wikipedia.org/wiki/Merge_sort#Top-down_implementation_using_lists
*
* for http://www.reddit.com/r/javaexamples
* by user /u/Philboyd_Studge
*
* PUBLIC LICENSE - This software is released with an unlimited license.
* There is no specification of any kind on its usage or implementation.
@snarkbait
snarkbait / BitStream.java
Created August 9, 2015 00:45
Huffman Tree example
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.