I have a couple of ideas I've been throwing around but I haven't found one I'm enough in love with to actually start the project. The closest one is based off of this image:
Actually doing something with it is going to take some time and effort... both of which I'm lacking at the moment.
//END OF LINE
Tuesday, March 5, 2013
Saturday, January 19, 2013
Interesting Tutorial
I've been working through this tutorial here. We'll see how things go with it, if they go anywhere.
I'll update as soon as I have something more to show than the programs that have been installed!
//END OF LINE
I'll update as soon as I have something more to show than the programs that have been installed!
//END OF LINE
Tuesday, January 15, 2013
I'm still breathing.
I just haven't found time to work on any exciting projects now that I have a full time job and have discovered the joys of British TV shows. Unfortunately, I've caught up on my Doctor Who and Sherlock and have to wait until April for anything new (curse you Moffat!!!). Hopefully I'll have some willpower and motivation to get something created and built to brag about in my small social circles.
//END OF LINE
//END OF LINE
Wednesday, July 18, 2012
Simple Chat Program
For my final project in networking I created a simple Server/Client Chat Program. This is the final version of the server side code.
//Necessary Libraries
import java.io.*;
import java.net.*;
import java.util.*;
//The Server Class contains all the classes and functions that
//this Chat Server needs to run
//Start this Class by calling the startHostingServer Function
class Server
{
//Holds the Socket connections with the Clients
private ArrayList connections;
private ArrayList dirtyWords;
//Class that will Handle the Client Connection
//This is a thread to allow multiple clients to
//be handled concurrently
public class ClientHandler implements Runnable
{
//Buffered reader for input from the Client
BufferedReader reader;
//The socket connection to the Client
Socket sock;
//The Constructor that will be used when creating a instance
//of this class. It takes as a parameter the Socket that
//has been set up with the Client
public ClientHandler(Socket clientSocket)
{
try
{
//Sets up sock and reader
sock = clientSocket;
InputStreamReader isReader = new InputStreamReader(sock.getInputStream());
reader = new BufferedReader(isReader);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
//This is what is run when the Thread is started
//Gets any messages from the client and lets all the other clients
//on this server know what the message is
public void run()
{
String message;
try
{
while((message = reader.readLine()) != null)
{
tellEveryone(filterMessage(message));
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//This is what is called to start the server
//Creates a new StartServer and starts the getConnections
//function
//This is called by the StartHosting Class
public void startHostingServer(int portNumber)
{
StartServer server = new StartServer();
server.setupDirtyWords();
server.getConnections(portNumber);
}
//This is the StartServer Class
//This starts the server and gets connections to the clients
public class StartServer
{
//This Sets up the dictionary that will be used to filter out
//the dirty words that may be used
public void setupDirtyWords()
{
dirtyWords = new ArrayList();
try
{
//This is the file where the list of dirty words
//are located at
File dwFile = new File("dirtyWords.txt");
FileReader fileReader = new FileReader(dwFile);
BufferedReader bufReader = new BufferedReader(fileReader);
String word;
while((word = bufReader.readLine()) != null)
{
dirtyWords.add(word + " ");
}
bufReader.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
//Accepts Client Connections to the Server
public void getConnections(int portNumber)
{
try
{
//Create the WelcomSocket for the Server to recieve Connections
ServerSocket welcomeSocket;
welcomeSocket = new ServerSocket(portNumber);
//Initializes the connections ArrayList
connections = new ArrayList();
//This is continually run to continue accepting connections for
//any host that may want to join
while(true)
{
Socket clientSocket = welcomeSocket.accept();
PrintWriter writer = new PrintWriter(clientSocket.getOutputStream());
connections.add(writer);
Thread t = new Thread(new ClientHandler(clientSocket));
t.start();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//send the message to everyone
public void tellEveryone(String message)
{
Iterator it = connections.iterator();
while(it.hasNext())
{
try
{
PrintWriter writer = (PrintWriter) it.next();
writer.println(message);
writer.flush();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//This is the actual filtering of the message
//This goes through the list of dirty words and makes sure
//none of those words are present in the message
public String filterMessage(String message)
{
for (int loop = 0; loop < dirtyWords.size(); loop++)
{
message = message.replaceAll(dirtyWords.get(loop).toString(), "*censored*");
}
return message;
}
}
//END OF LINE
//Necessary Libraries
import java.io.*;
import java.net.*;
import java.util.*;
//The Server Class contains all the classes and functions that
//this Chat Server needs to run
//Start this Class by calling the startHostingServer Function
class Server
{
//Holds the Socket connections with the Clients
private ArrayList connections;
private ArrayList dirtyWords;
//Class that will Handle the Client Connection
//This is a thread to allow multiple clients to
//be handled concurrently
public class ClientHandler implements Runnable
{
//Buffered reader for input from the Client
BufferedReader reader;
//The socket connection to the Client
Socket sock;
//The Constructor that will be used when creating a instance
//of this class. It takes as a parameter the Socket that
//has been set up with the Client
public ClientHandler(Socket clientSocket)
{
try
{
//Sets up sock and reader
sock = clientSocket;
InputStreamReader isReader = new InputStreamReader(sock.getInputStream());
reader = new BufferedReader(isReader);
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
//This is what is run when the Thread is started
//Gets any messages from the client and lets all the other clients
//on this server know what the message is
public void run()
{
String message;
try
{
while((message = reader.readLine()) != null)
{
tellEveryone(filterMessage(message));
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//This is what is called to start the server
//Creates a new StartServer and starts the getConnections
//function
//This is called by the StartHosting Class
public void startHostingServer(int portNumber)
{
StartServer server = new StartServer();
server.setupDirtyWords();
server.getConnections(portNumber);
}
//This is the StartServer Class
//This starts the server and gets connections to the clients
public class StartServer
{
//This Sets up the dictionary that will be used to filter out
//the dirty words that may be used
public void setupDirtyWords()
{
dirtyWords = new ArrayList();
try
{
//This is the file where the list of dirty words
//are located at
File dwFile = new File("dirtyWords.txt");
FileReader fileReader = new FileReader(dwFile);
BufferedReader bufReader = new BufferedReader(fileReader);
String word;
while((word = bufReader.readLine()) != null)
{
dirtyWords.add(word + " ");
}
bufReader.close();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
//Accepts Client Connections to the Server
public void getConnections(int portNumber)
{
try
{
//Create the WelcomSocket for the Server to recieve Connections
ServerSocket welcomeSocket;
welcomeSocket = new ServerSocket(portNumber);
//Initializes the connections ArrayList
connections = new ArrayList();
//This is continually run to continue accepting connections for
//any host that may want to join
while(true)
{
Socket clientSocket = welcomeSocket.accept();
PrintWriter writer = new PrintWriter(clientSocket.getOutputStream());
connections.add(writer);
Thread t = new Thread(new ClientHandler(clientSocket));
t.start();
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//send the message to everyone
public void tellEveryone(String message)
{
Iterator it = connections.iterator();
while(it.hasNext())
{
try
{
PrintWriter writer = (PrintWriter) it.next();
writer.println(message);
writer.flush();
}
catch(Exception ex)
{
ex.printStackTrace();
}
}
}
//This is the actual filtering of the message
//This goes through the list of dirty words and makes sure
//none of those words are present in the message
public String filterMessage(String message)
{
for (int loop = 0; loop < dirtyWords.size(); loop++)
{
message = message.replaceAll(dirtyWords.get(loop).toString(), "*censored*");
}
return message;
}
}
//END OF LINE
Tuesday, July 3, 2012
Just looking at some of the projects I've worked on in the past. One of my favorite was a group project me and some guys from some of my classes did was this networked bingo game. You can download the .jar files and view all the source code here.
We used threads to run the server based part (originally it was a stand alone game and then we networked it, so we tried to keep most of the original structure intact). Here's the run function:
Some simple stuff, but we were really proud to get it working.
//END OF LINE
We used threads to run the server based part (originally it was a stand alone game and then we networked it, so we tried to keep most of the original structure intact). Here's the run function:
| public void run() |
| { |
| try |
| { |
| //Set the port number |
| int port = 1352; |
| //Establish the listen socket. |
| ServerSocket welcomeSocket = new ServerSocket(port); |
| InetAddress addr = InetAddress.getLocalHost(); |
| String ip = addr.getHostAddress(); |
| mMessage.setText(" Server IP Address: " + ip); |
| //Process service requests in an infinite loop |
| while (true) |
| { |
| //Listen for a TCP connection request |
| Socket connectionSocket = welcomeSocket.accept(); |
| // Construct an object to process the request. |
| BingoHandler request = new BingoHandler(connectionSocket); |
| // Create a new thread to process the request. |
| Thread thread = new Thread(request); |
| // Start the thread. |
| thread.start(); |
| } |
| } |
| catch (Exception e) |
| { |
| } |
| } |
Some simple stuff, but we were really proud to get it working.
//END OF LINE
Wednesday, June 27, 2012
A Beginner's Example
I know, I know... No posts in forever... I'm sorry and I really don't have any good excuses except that I've been lazy... but I'll try to be more consistent now.
If you are not a beginner, you certainly don't need to read the rest of this post. If you do continue please feel free to mock any stupid mistakes I may have made.
Anywho... I come from two wonderful parents who are both actually very into computers. Growing up we always had to have the latest and greatest in technology and I don't think we ever had less than 3 working computers and many different parts. My dad has always been into the security aspect of programs which has never been one of my interests. My mother actually was a programmer back in the day of COBOL and PASCAL, but since she's had kids she's been a stay at home mom and the programming languages and techniques are very, very different.
Recently she's wanting to get back into coding and asked me for some tips and advice on where to start. I suggested a book that I had used for my Java class and sent her a few examples I had quickly created that were simple. This is one of the examples I sent. It's simply a Dog class with a few variables and functions.
class Dog
{
//These are private member variables
//They can ONLY be accessed by the Dog
//classes functions
private String dogName;
private String dogSound;
private String breed;
//This is what is called the Constructor
//This gets called when a new instance of
//the class is created
public Dog(String name, String noise)
{
dogName = name;
dogSound = noise;
}
public Dog(String name, String noise, String b)
{
dogName = name;
dogSound = noise;
breed = b;
}
//This function is going to display the noise
//the dog makes when it barks
public void bark()
{
System.out.print(dogName + " says: " + dogSound);
System.out.print(" " + dogSound + "!\n");
}
public String getBreed()
{
return breed;
}
}
The Dog Driver class just creates a couple of instances of the Dog class to demonstrate how to use it.
class DogDriver
{
public static void main (String args[])
{
//These to lines call the Constructor of the Dog
//class and create new instances of the Dog class
Dog chihuahua = new Dog("Joey", "Yip");
Dog germanShepard = new Dog("Max", "Woof");
Dog corgi = new Dog("Sam", "Moo", "Corgi");
Dog poodle = new Dog("Lulu", "Bark");
//These two lines call the bark function of the Dog
//class and make the Dogs bark
chihuahua.bark();
germanShepard.bark();
poodle.bark();
corgi.bark();
System.out.println(corgi.getBreed());
}
}
It's going to be an interesting experience trying to get her away from the linear concept and more comfortable with the object oriented approach, but I think it'll be a good way for me to brush up on my rusty techniques and a great review for me.
//END OF LINE
If you are not a beginner, you certainly don't need to read the rest of this post. If you do continue please feel free to mock any stupid mistakes I may have made.
Anywho... I come from two wonderful parents who are both actually very into computers. Growing up we always had to have the latest and greatest in technology and I don't think we ever had less than 3 working computers and many different parts. My dad has always been into the security aspect of programs which has never been one of my interests. My mother actually was a programmer back in the day of COBOL and PASCAL, but since she's had kids she's been a stay at home mom and the programming languages and techniques are very, very different.
Recently she's wanting to get back into coding and asked me for some tips and advice on where to start. I suggested a book that I had used for my Java class and sent her a few examples I had quickly created that were simple. This is one of the examples I sent. It's simply a Dog class with a few variables and functions.
class Dog
{
//These are private member variables
//They can ONLY be accessed by the Dog
//classes functions
private String dogName;
private String dogSound;
private String breed;
//This is what is called the Constructor
//This gets called when a new instance of
//the class is created
public Dog(String name, String noise)
{
dogName = name;
dogSound = noise;
}
public Dog(String name, String noise, String b)
{
dogName = name;
dogSound = noise;
breed = b;
}
//This function is going to display the noise
//the dog makes when it barks
public void bark()
{
System.out.print(dogName + " says: " + dogSound);
System.out.print(" " + dogSound + "!\n");
}
public String getBreed()
{
return breed;
}
}
The Dog Driver class just creates a couple of instances of the Dog class to demonstrate how to use it.
class DogDriver
{
public static void main (String args[])
{
//These to lines call the Constructor of the Dog
//class and create new instances of the Dog class
Dog chihuahua = new Dog("Joey", "Yip");
Dog germanShepard = new Dog("Max", "Woof");
Dog corgi = new Dog("Sam", "Moo", "Corgi");
Dog poodle = new Dog("Lulu", "Bark");
//These two lines call the bark function of the Dog
//class and make the Dogs bark
chihuahua.bark();
germanShepard.bark();
poodle.bark();
corgi.bark();
System.out.println(corgi.getBreed());
}
}
It's going to be an interesting experience trying to get her away from the linear concept and more comfortable with the object oriented approach, but I think it'll be a good way for me to brush up on my rusty techniques and a great review for me.
//END OF LINE
Tuesday, April 10, 2012
I'm still alive
I apologize for my lack of posts... I've been working with SharePoint and it's taking all my power not throw my computer...
Hopefully soon you'll be hearing more about some of my projects I'll be starting now that I've graduated.
Also I've discovered a humorous and attractive side of Mr. Gosling for us nerdy girls :)
//END OF LINE
Hopefully soon you'll be hearing more about some of my projects I'll be starting now that I've graduated.
Also I've discovered a humorous and attractive side of Mr. Gosling for us nerdy girls :)
//END OF LINE
Subscribe to:
Posts (Atom)