Skip to content

Instantly share code, notes, and snippets.

@MrBean83
MrBean83 / DrunkWalker.java
Last active August 29, 2015 14:21
"Drunk Walker" Program
/*
Builds a Java program that generates a ‘random’ (drunk) walk across a 10 X 10 array.
Initially the array will contain all periods(‘.’)
The program must randomly ‘walk’ from element to element;
Always going up, down, right, or left (no diagonal) by one element.
@MrBean83
MrBean83 / Password.java
Created May 12, 2015 16:38
Simple JOptionPane examples in Java
/*****************************************************
*
* Program Name: Password
*
* Author: Henry Nichols
*
* Remarks: JOptionPane examples
*
*****************************************************/
@MrBean83
MrBean83 / HelpGUI.java
Last active August 29, 2015 14:21
Simple JList GUI for Java keywords
// Builds a simple JList GUI that displays implementation descriptions for keywords when one is selected
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
class HelpGUI implements ListSelectionListener, ActionListener {
JButton close;
@MrBean83
MrBean83 / StringOddEven.java
Created May 12, 2015 16:07
Prints out string if string length is even; prints out reversed copy of string if string length is odd.
import javax.swing.JOptionPane;
public class StringOddEven {
public static void main(String args[]) {
String input = JOptionPane.showInputDialog("Please enter a string.");
int length = input.length();
if (length % 2 == 0) {
System.out.println(input);
} else {
@MrBean83
MrBean83 / Fibonacci.java
Created May 12, 2015 15:58
Iterative Fibonacci Sequence
public class Fibonacci {
public static void main(String args[]) {
// Declare variables
int index = 0, first = 0, second = 1;
System.out.println("Fibonacci Sequence");
System.out.println();
// Using a WHILE loop for this program.
while (index < 21) {
@MrBean83
MrBean83 / FizzBuzz.java
Created May 12, 2015 15:52
Simple "Fizz Buzz" Program
class FizzBuzz {
public static void main(String args[]) {
// Declare local variables
int num;
// Using a FOR loop for this program.
for (num = 1; num < 73; num++) {
if (num % 35 == 0)
System.out.println("FizzBuzz");
else if (num % 7 == 0)
@MrBean83
MrBean83 / LeapYear.java
Last active August 29, 2015 14:21
Simple "Leap Year" Program
import java.util.Scanner;
class LeapYear {
public static void main(String args[])
{
// Declare variables
int year;
boolean status;
Scanner scanIn = new Scanner(System.in);
@MrBean83
MrBean83 / LogicalOpTable.java
Created May 12, 2015 15:12
Logical Operations Table
// Print a truth table for the logical operators.
class LogicalOpTable {
public static void main(String args[]) {
boolean p, q;
int pVal = 0, qVal = 0, pqAndVal= 0, pqOrVal = 0, pqExOrVal = 0, pNotVal = 0;
System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");
@MrBean83
MrBean83 / zoo.js
Created October 17, 2013 16:33 — forked from dbc-challenges/zoo.js
Phs2_PrAss_Pt. 4 OOJS: Tending the Zoo
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
function Animal(name, number_of_legs) {
this.name = name;
this.number_of_legs = number_of_legs;
}
Animal.prototype.identify = function(){
@MrBean83
MrBean83 / index.html
Created October 17, 2013 15:52 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>