Skip to content

Instantly share code, notes, and snippets.

View rjlutz's full-sized avatar

Bob Lutz rjlutz

  • Georgia Gwinnett College
  • Lawrenceville, GA
View GitHub Profile
@rjlutz
rjlutz / ComputeAngles.java
Last active June 19, 2017 20:57
Math, Characters, Strings (Chapter 4) - examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class ComputeAngles {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Prompt the user to enter three points
System.out.print("Enter three points: ");
double x1 = input.nextDouble();
double y1 = input.nextDouble();
@rjlutz
rjlutz / Dec2Hex.java
Last active June 26, 2017 18:18
Loops (Chapter 5) - examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class Dec2Hex {
/** Main method */
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter a decimal integer
System.out.print("Enter a decimal number: ");
@rjlutz
rjlutz / GreatestCommonDivisorMethod.java
Last active June 28, 2017 16:54
Methods (Chapter 6) -- examples from Liang Intro to Java Comprehensive 10e
import java.util.Scanner;
public class GreatestCommonDivisorMethod {
/** Main method */
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Prompt the user to enter two integers
System.out.print("Enter first integer: ");
@rjlutz
rjlutz / AnalyzeNumbers.java
Created July 17, 2017 20:44
Single Dimensional Arrays (Chapter 7) -- examples from Liang Intro to Java Comprehensive 10e
public class AnalyzeNumbers {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Enter the number of items: ");
int n = input.nextInt();
double[] numbers = new double[n];
double sum = 0;
System.out.print("Enter the numbers: ");
for (int i = 0; i < n; i++) {
@rjlutz
rjlutz / CircleWithPrivateDataFields.java
Created July 17, 2017 21:30
Objects (Chapter 9) -- examples from Liang Intro to Java Comprehensive 10e
public class CircleWithPrivateDataFields {
/** The radius of the circle */
private double radius = 1;
/** The number of the objects created */
private static int numberOfObjects = 0;
/** Construct a circle with radius 1 */
public CircleWithPrivateDataFields() {
numberOfObjects++;
@rjlutz
rjlutz / Bubble.pde
Last active August 17, 2017 13:11
A Really Simple Demonstration of Processing Using Active Mode and a Bubble Class
public class Bubble {
int x, y;
float r;
int incrX = (int) random(4,8);
int incrY = (int) random(2,8);
int red, green, blue, alpha;
public Bubble() {
x = (int)random(width);
@rjlutz
rjlutz / edit html
Last active January 16, 2018 21:35
notesf for basic cordova app w/notification dialog
add
<button id="aboutBtn">About</button>
@rjlutz
rjlutz / steps
Last active January 30, 2018 22:46
Steps to import Wargo's 14.1 Media Player Example
download or clone https://github.com/johnwargo/apache-cordova-api-cookbook-code
cordova create ...
cordova platform add android
graft content from
~/Downloads/apache-cordova-api-cookbook-code-master/chapter14-media/Ex14.1 (your downloads, of course)
cordova plugin add cordova-plugin-media
cordova plugin add cordova-plugin-device
@rjlutz
rjlutz / Circle.pde
Last active August 31, 2017 15:27
ITEC 2150 Chapter 11 Inheritance
public class Circle extends Shape {
private float r; // r is the radius of the circle
public Circle(float a, float b, float c) {
super(); // this is effectively like new Shape()
x = a;
y = b;
r = c;
// accept Shape's default of filled=false
@rjlutz
rjlutz / AppleTester.java
Last active April 21, 2022 16:21
Inheritance and Polymorphism (Chapter 11) -- examples from Liang Intro to Java Comprehensive 10e
public class AppleTester {
public static void main(String[] args) {
Apple apple = new Apple();
System.out.println(apple.toString());
}
}
public class Apple extends Fruit {