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.

Generics’ Bounded Wild Cards in Java PRO

When using a bounded wild card we can limit the parametric type as if we were saying that it can be any type as long as it extends or implements a specific type we specify.

package il.ac.hit.samples;

import java.util.Iterator;
import java.util.Vector;

public class BoundedWildCardSample
{
	public static double calculateTotal(Vector<? extends Shape> vicy)
	{
		double sum = 0;
		Iterator<? extends Shape> iterator = vicy.iterator();
		while (iterator.hasNext())
		{
			sum += iterator.next().area();
		}
		return sum;
	}

	public static void main(String args[])
	{
		double total = 0;
		Vector<Circle> victor = new Vector<Circle>();
		victor.add(new Circle(4));
		victor.add(new Circle(8));
		victor.add(new Circle(2));
		// victor.add(new Rectangle(4,2));
		// victor.add(new Rectangle(5,4));
		total = calculateTotal(victor);
		System.out.println("total=" + total);
	}
}

The following video clip shows how to use bounded wild cards and provides more in-depth explanation.

Share:

The Beauty of Code

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

Update cookies preferences