Daycare Updater System

I haven’t posted in a while because I’ve been so busy with finals and starting my internship at USGS. Just wanted to post a quick update on my Daycare Management System. The program now has a self sustaining update system, written from scratch, that notifies the user on start-up if a new version is available. The user is prompted to click update (Yes or No). If choosing yes, the download will commence and the new file will be placed in the correct directory. No code sample, sorry. It’s not the best code and does need refactoring, but it does work 100%. When I get around to refactoring, I’ll post a code sample.


Daycare Installation System

So I’ve finished the installation system for my Daycare Management System. The system works very well. What happens is if the program cannot find the config.xml file in one of the default program directories located on the user’s computer, the program assumes that the user has not installed the program. Thus, the program invokes the installation screen and displays it to the user, prompting them to install the program. The installation creates the required directories and files within those directories.

Some code for creating a new file:

	 * <p>Creates a new file with specified name.
	 * @param name the name of the file to create
	private boolean createFile(String name)
		boolean success = false;

		try {
			success = new File(name).createNewFile();

			if (!success)
				System.out.println("Error creating file [" + name + "] during installation...");
				System.out.println("Creating file [" + name + "]");
		} catch (IOException e) {

		return success;

After creating the above files, I then populate them with another method. The way I populate them with text is by reading from some text files that have been packaged with the program. I read from the files and write to the new files in the program’s root directory.

Daycare Login System

I finished the login system to my Daycare Management System. In order to login, the user must obviously have created an account, which will store an XML account file locally on their computer. When the user enters their username and password, the program queries the account directory and matches the username with the XML file names. If there’s a match, the XML file is opened and the entered password is MD5 hashed and matched with the hashed password in the XML file. If all matches, the user is logged in, otherwise the user is prompted that their username or password is incorrect.

The code for validating a user’s login credentials:

	 * <p>Compares the username and password entered by the user with the correct
	 * username and password stored in the Accounts folder.
	 * @return whether or not the username and password match the ones stored for the particular account.
	public boolean validateLogin()
		SAXBuilder builder;
		Document doc;
		Element root;
		String file = username + ".xml";

			builder = new SAXBuilder();
			doc = File("Accounts/" + file));
			root = doc.getRootElement();
		} catch (Exception e) {
			return false;

		String user = root.getChildText("username");
		String pass = root.getChildText("password");
		encryptedPassword = new Encryption().MD5(password);

		// If username and password match one in the Accounts folder
		if (username.equalsIgnoreCase(user) && encryptedPassword.equalsIgnoreCase(pass))
			// Set last login to current time
			DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
			Date date = new Date();
			String d = dateFormat.format(date);

			// Save the file
				FileWriter writer = new FileWriter("Accounts/" + file);
				XMLOutputter outputter = new XMLOutputter();
				outputter.output(doc, writer); // Save the new document
			} catch (IOException e) {
				System.out.println("IOException while writing the new XML file for account: \"" + username + "\"");

			return true;
			return false;

Cut Rod Dynamic Programming

As part of an assignment for my ‘Design and Analysis of Algorithms’ course, the class was required to find the maximum revenue rj and optimal size sj of the first piece to cut off for each rod size j. We were given the following price table:

length i 1 2 3 4 5 6 7 8 9 10
price p[i] 1 8 8 9 9 11 13 17 26 37

Given the problem, I’ve written the following algorithm in Python, using the pseudocode from p.369 of Cormen’s Introduction to Algorithms standard textbook:

Image Glare Removal Algorithm

Here at Eckerd College we have a program in development for the marine science students, called ‘DARWIN.’ From “DARWIN is a software system which allows marine scientists to maintain information for the study of various behavioral and ecological patterns of bottlenose dolphins, Tursiops truncatus. The software provides a graphical user interface to access a collection of digital dorsal fin images along with textual information which describes individual animals as well as relevant sighting data. Users may query the system with the name of a specific individual or the entire collection may be sorted and viewed based upon sighting location, sighting date, or damage category. Alternatively, the researcher may query a database of previously identified dolphin dorsal fin images with an image of an unidentified dolphin’s fin. DARWIN responds with a rank ordered list of database fin images that most closely resemble the query image.”

Early my junior year, I was asked if I would like to develop an algorithm for the DARWIN program. The algorithm would be used to remove image glare from user selected areas of the images supplied by the user. Although DARWIN is written in C++, I have started writing the algorithm in Java because I can easily view the results of my algorithm with the use of Swing. I’m not well versed in GTK+; so, after completing the algorithm with satisfactory results, I will sit down to port the program over to C++ with the project advisor, Prof. Kelly Debure.

The initial algorithm that came to mind was the following algorithm:
Note: Multi-line comments have been removed.

public BufferedImage removeGlare(Point x, Point y)
    final int NORMAL = 5; // Normal matrix size = 5*5
    final int SMALL = 3; // Small matrix size = 3*3
    int[][][] matrix; // Matrix to hold all pixel values around every single pixel within the selected area