Archive for 'Java'

Android Activity Lifecycle

Android Visualization Lab – University of California, Berkeley

“Like HTML webpages, Android provides functionality for setting up and tearing down. HTML provides the ability to respond to events through triggers like onLoad and onUnload. Android provides eight such methods, each to respond to a very specific situation.”
(Berkeley, University of California retrieved from:
http://vis.berkeley.edu/courses/cs160-sp08/wiki/index.php/Getting_Started_with_Android 12/22/2011)

Android API Reference

http://code.google.com/android/reference/android/app/Activity.html

Android Package Index

http://developer.android.com/reference/packages.html

Android Class Index

http://developer.android.com/reference/classes.html

Android Download

http://developer.android.com/sdk/index.html

Android Videos

http://developer.android.com/videos/

Android Developers Guide

http://developer.android.com/guide

Android Market

Read more →

Java Swing Applet Calculator

Simple Budget Calculator

Created with Java Swing Applet

Click here to see the demo live.
You must have the Java jdk installed on your computer for the applet to work.

Java Applet Code

// Swing applet calculator demo

import java.awt.Graphics;
import javax.swing.JApplet;
import javax.swing.JOptionPane;

public class budgetCalculator extends JApplet
{
private double sum; // sum of values

// initialize applet
public void init()
{
// input total income from user
String incomeNumber = JOptionPane.showInputDialog(
“Enter your total income”);

//inupt total expenses from user
String expenseNumber ...

Read more →

Artificial Life – Simple Animation

One of the base things I must accomplish in the creation of a software program that emmulates the evolution and survival of life is a simplistic method of animating graphical objects. The graphics will be able to “see” and therefore will sense when they come in close contact with other objects. After a bit of research and development, I found an existing program, written in Java, that does just this.

The artificial life simulation will take into account the cycle of ...

Read more →

Artificial Life – Simple Math

The following code transforms the struggle for survival into a mathematical equation. A user is asked to enter a number of carnivores to create between 1 – 100. Once the number has been decided, the plants, herbivores and carnivores reproduce contingent on a specific ratio between plants:herbivores:carnivores or 16:6:2.

The program takes 3 separate life forms plants, herbivores and carnivores and increases or decreases their reproduction rate depedent on their ratio in comparison to the other life forms. A ratio of ...

Read more →

Artificial Life Simulation

I have many software projects that I have been working on. One of my favorites is an Artificial Life Simulation. I will be using the blog portion of mikestratton.net to keep a running record of my work. The Artificial Life Simulation is being developed in Java.

Artificial Life Simulation Overview

Create a simulation that emulates life and evolution.
The simulation is governed by the same rules that govern our world. Graphic
objects in simulation represent life forms and environmental objects. Life
forms ...

Read more →

Duke the Java Mascot!

Duke the Java Mascot!

This is Duke, the Java Mascot. Duke and I share one thing in common, we both
love Java! To show my support for Duke and all of his Java escapades, I have
added his portrait to this site!

Duke the Java Mascot!

Would you like to learn more about the Java platform? Go to: http://www.java.com

Would you like to learn more about Duke, the Java Mascot? Go to:

http://kenai.com/projects/duke/pages/Home

Read more →

Java Fractal Examples

Java Fractal Examples

What exactly is a fractal? Wikipedia defines a fractal as “a rough or fragmented geometric shape that can be split into parts, each of which is (at least approximately) a reduced-size copy of the whole,”[1] a property called self-similarity.

Java Fractals – Artistic Expression

I have created some Java fractals for two purposes.
1) Computer Science Artistic Expression
2) Examples of Fractals written in Java

To view the fractals, click here: Fractal Gear Machine

References

Deitel P. & Deitel ...

Read more →

Java Exception Handling

Java Exception Handling

Moutain State University Java Study Notes
(Week 1 CIS 220 Computer Science II)

Java exception handling is based in part on Andrew Koenig's and Bjarne
Stroustrup's paper, "Exception Handling for C++ (revised).
(Reference: A. Koenig, and B. Stroustrup, "Exception Handling for C++
(revised)." Proceedings of the Usenix C++ Conference, pp. 149-176, San
Francisco, April 1990.)

Only classes that extend THROWABLE (package.java.lang) dirctly or indirectly
can be used with exception handling.

Error Handling Overview Psuedocode

Perform a task

If the preceeding task did ...

Read more →

Java Math.PI Circle Radius

Mountain State University Java Assisgnment

2.28 (Diameter, Circumference, and Area of a Circle

Write an application that inputs from the user the radius of a circle as an integer and prints the circle’s diameter, circumference, and area using the floating-point 3.14159 for PI.

Java circlePi.java Source Code

import java.util.Scanner;

public class circlePi {

public static void main( String[] args )
{
Scanner input = new Scanner( System.in );

int cRadius; //radius of circle

System.out.print( "Enter the radius of a circle " ); // prompt for user input
Read more →

Java Palindrome

Mountain State University Java Assignment

3.30 (Palindromes)

Write an application that reads in a five digit integer and determines whether it’s a palindrome. If the number is not five digits long, display an error message and allow the user to enter a new value.

Java Palindrome Source Code

import java.util.Scanner; //initialize scanner

public class palindrome // defines class name
{

public static void main( String[] args )
{
// Scanner = new Scanner( System.in );
Scanner input = new Scanner( System.in );

int digit; // enter 5 ...

Read more →
Page 1 of 2 12

# #