The silliest project ever (and for silly I mean tremendously difficult!)

This week I finally finished #wsq09 “Movies”. I worked in this task for over two weeks; I spent nights in front of my laptop; I couldn’t slept because this task tormented me, but at last I beat one of the most difficult tasks of my life! Here is the description of my experience doing this incredibly, extremely, tremendously, awfully difficult wsq09.

The instructions for this task were: create a program that read a file, outside the program of course, with the names of some actors and movies where they have appeared. You should record this information wherever you want, and ask the user for an input: if the user write two movies separated by either “|”, “&” or “^”, the program should output the actors of the movies the user wrote with their respective restriction. “|” stands for all the actors that appeared in each movie (logic gate OR); “&” stands for all the actors that appeared in both movies (logic gate AND); and “^” stands for all the actors that appeared in one of the movies, but not both (logic gate XOR). Finally there was another option: the user could write the name of an actor and the program should find all the actors with whom he/she has acted in any movie.

The chosen tool or what I called it, the ‘designed hitter’ tool I used was a HashMap. This tool works as a Python’s dictorionary, where you have a key and a set of values of that key. There was only one important problem with the HashMap, the program couldn’t have access to the HashMap once running, in other words, I couldn’t read the HashMap line by line just like an ArrayList or any other similar tool. Once the HashMap was created by reading the file, an ArrayList of every key with their respective values was created too. Now with the movies and their respective actors arranged, an inputBox was shown so the user could wrote whichever option he/she wants and the output would be the actors with the selected restriction.

Another important aspect of my code is the use of an Iterator for displaying the actors in the option ‘b’ where the user simply write the name of an actor, and the program should return all the actors whom he/she has appeared with. The Iterator is an object that works when calling the method ‘iterator ()’. This object enables you to cycle through a collection of data, helping to obtain or remove elements. I used the Iterator to search for the name of the actor, and collect all other actors that appeared in the same list.

Here I leave the link to my Github repository where my classmates can see my code.

Hope that I help someone because this task is tremendously hard!



Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión /  Cambiar )

Google photo

Estás comentando usando tu cuenta de Google. Cerrar sesión /  Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión /  Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión /  Cambiar )

Conectando a %s