This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tetris; | |
import java.awt.*; | |
import javax.swing.*; | |
import java.awt.event.KeyEvent; | |
import java.awt.event.KeyListener; | |
import java.io.IOException; | |
import java.util.*; | |
import java.lang.Thread; | |
import javax.sound.sampled.*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.util.*; | |
import java.awt.Color; | |
import java.util.Random; | |
public class SandLab | |
{ | |
public static void main(String[] args) | |
{ | |
SandLab lab = new SandLab(120, 80); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Vehicle.java | |
public class Vehicle { | |
String color; | |
} | |
//Truck.java | |
public class Truck extends Vehicle { | |
int bedLength; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Rational{ | |
private int numerator; | |
private int denominator; | |
int getNumerator() { | |
return numerator; | |
} | |
int getDenominator() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.Arrays; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class SplitWord { | |
public static void main(String[] args){ | |
Scanner sc = new Scanner(System.in); | |
System.out.println( | |
"This program will split those characters into array items delimited by the comma.\n" + |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.Scanner; | |
import java.util.Random; | |
public class HangMan { | |
final String[] words = { | |
"abandon", | |
"cabaret", | |
"eagerly", | |
"habitat", | |
"iceberg", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MergeArrays { | |
public static void main(String[] args) { | |
int[][] arrays = {{1,2,3},{14,15,16,17}}; | |
int mergedArrayLen = arrays[0].length + arrays[1].length; | |
int[] mergedArray = new int[mergedArrayLen]; | |
int mergedArrayIndex = 0; | |
for(int i = 0; i < arrays.length; i++){ | |
for(int j = 0; j < arrays[i].length; j++) { | |
mergedArray[mergedArrayIndex] = arrays[i][j]; | |
mergedArrayIndex++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.ArrayList; | |
public class Metrics { | |
public static void main(String[] args) { | |
ArrayList<Integer> hieghtInInches = new ArrayList<Integer>(); | |
ArrayList<Integer> weightInPounds = new ArrayList<Integer>(); | |
String request = "Please add height(in inches) and weight(in pounds) for each " + | |
"person seperated by a colon. When you are done enter the letter Q."; | |
System.out.println(request); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultiDimensionalArray { | |
public static void main(String[] args){ | |
int[][] arrayOfArrays = new int[10][]; | |
for (int i = 0; i < 10; i++){ | |
arrayOfArrays[i] = new int[i + 1]; | |
for(int j = 0; j < i + 1; j++){ | |
arrayOfArrays[i][j] = j; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClass { | |
public static void main(String args[]) { | |
int numerator1 = 3; | |
int denominator1 = 5; | |
int numerator2 = 2; | |
int denominator2 = 15; | |
numerator1 = numerator1 * denominator2; | |
numerator2 = numerator2 * denominator1; | |
NewerOlder