Blog Navigation
Partners
Latest Activity
Phil explains how to use the old telephone tones to wane off telemarketers!
Posted on: February 26th, 2011 by Famous Phil
It has been a while since I’ve done any sort of real coding for my website and I’ve been meaning to go back and post some of my old projects that work really well and show what is really good code. Today I’ve decided to bring attention to my RMI chat client and server that I wrote for a class about 2 years ago now. I recently had to refer to myself when implementing RMI code in another project and was hard pressed to find my old project. Since my site is an archive of my work for the future, I thought that it might be appropriate to post this code now.
First, to compile Java code, you need to get the Java development kit (JDK) from Oracle’s Java Download Page. Then you need to run the command “javac” on all the .java files to get the .class files. Finally to invoke the code, you need to make use of the Java command. I’ve tested this project on both Windows and Linux and both work fine, both locally and over a remote network link. Although I’m not going to guarantee support for this code, you may feel free to email me (contact page) if you’d like some help beyond what the readme file says.
You may get the code from here: http://famousphil.com/wp-content/uploads/2011/02/RMIChatServer.zip
Tags: chat, client, java, Programming, rmi, server
Posted in Programming
|| 1 Comment »
Posted on: January 27th, 2011 by Famous Phil
I was bored today with John and we thought we’d make a ball move on the screen. After 10 minutes we decided to do a Monte Carlo simulation with the ball to get a cool drawing. Forty minutes later, here is what we came up with, it kind of looks like a dog or a cow’s head
Here is the code that produced this:
package us.matthouse.circle;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;
import javax.swing.JFrame;
import javax.swing.Timer;
public class Circle extends JFrame implements ActionListener{
Timer t;
int x = 300;
int y = 300;
int z[][] = new int[600][600];
public Circle(){
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(600, 600);
this.setLocation(50, 50);
setVisible(true);
for(int i=0; i<600; i++){
for(int j=0; j<600; j++){
z[i][j] = 0;
}
}
t = new Timer(10, this);
t.start();
}
public void paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0, 0, 600, 600);
g.setColor(Color.black);
for(int i=0; i<600; i++){
for(int j=0; j<600; j++){
if(z[i][j] == 1){
g.fillRect(i, j, 1, 1);
}
}
}
g.setColor(Color.green);
g.fillOval(x, y, 5, 5);
}
public static void main(String[] args){
new Circle();
}
public void actionPerformed(ActionEvent e){
Random r = new Random();
int k = r.nextInt(3) - 1;
x = x + k;
k = r.nextInt(3) - 1;
y = y + k;
z[x][y] = 1;
if (y < 50){
y++;
}else if(x < 50){
x++;
}else if(x > 550){
x--;
}else if(y > 550){
y--;
}
repaint();
}
}
Tags: Circle, java, John Ciacia, Monte Carlo, Programming
Posted in Programming
|| No Comments »
Posted on: April 27th, 2009 by Famous Phil
So, I was thinking that I should drift a little bit to my personal life and talk a little bit about my public speaking skills which seem to be severely lacking. Of course, this idea came to me in the shower like most of my better (or worse??) ideas do.
About 3 to 4 weeks ago, I decided that I wanted to become a Teaching Assistant (TA) for the Computer Science Department (CSE) for the entry level course that teaches students Java (The programming language distributed by SUN). I went through the interview fine and was asked to give a 10 minute presentation/lecture on what a Constructor is at the level a CSE115 (entry level course) student.
I didn’t know too much about the constructor other than it is the part of a class that instantiates that class. I went into that lecture knowing a lot about the constructor but I did not rehearse anything. I also know what I expect out of public speakers as an active listener, therefore, I went in with no power point and rather wanted to just experiment in the Java compiler and explain what everything was line by line from real code. I wrote a bunch of partial examples in Java prior to my presentation to make sure that I would be prompted to not miss anything important. Although I doubt I missed anything important, I know that I definitely did not explain anything well. I would have done much better just reading off a slide and a note sheet (which I hate when public speakers do).
Tags: computer science, constructor, cse, java, lecture, lecture series, presentation, public speaking, random numbers, university at buffalo
Posted in Personal, Student Life, Uncategorized
|| 1 Comment »