Game Instructions

Tap a tile to toggle its color. When a tile changes nearby tiles may change as well. Each move affect multiple tiles. The target is to turn all tiles into yellow in the fewest steps possible.

Press 'j' to show/hide the game. Press 'i' to show/hide the instructions. Press 't' to show/hide the top score table.

Steps: 0

Top Scores

Name Steps
Press J to toggle the game, I to toggle instructions, and T to toggle the top scores

Congratulations!

You solved the puzzle in 0 steps!

Success!

Score submitted successfully!

Error

Failed to submit score. Please try again.

The Java 7 try-with-resources Statement PRO

As of Java 7 we can code a try statement that declares one or more resources. Each resource is an object that must be closed after the program is finished. The try-with-resources statement ensures that each resource is closed at the end of the statement. Each object considered as a resource must be instantiated from a class that implements java.lang.AutoCloseable.

package com.abelski.samples;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class TryResourcesDemo
{
	public static void main(String[] args)
	{
		try
		{
			String str = readTextFile("bb.txt");
			System.out.println(str);
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}

	static String readTextFile(String path) throws IOException 
	{
		StringBuilder builder = new StringBuilder();
		try (BufferedReader br = new BufferedReader(new FileReader(path))) 
		{
			String str = null;
			while((str = br.readLine())!=null)
			{
				builder.append(str).append("\n");				
			}
		}
		return builder.toString();
	}
}

The following video clips shoes the execution of this code sample and explains it.

Share:

The Beauty of Code

Coding is Art! Developing Code That Works is Simple. Develop Code with Style is a Challenge!

Update cookies preferences