Created
October 31, 2013 13:37
-
-
Save iamricard/7249860 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.*; | |
import java.io.*; | |
class Ejercicio4 { | |
public static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); | |
// public static String[][] peliculas = new String[5][2]; | |
public static final byte director = 2; | |
public static final byte genero = 1; | |
public static final byte titulo = 0; | |
public static void main(String[] args) throws IOException { | |
System.out.println("BIENVENIDO A VIDEOTECA"); | |
Videoteca videoteca = new Videoteca(); | |
// <dev> | |
videoteca.addMovie("Batman: The Dark Knight", | |
"Accio", | |
"Bona peli de batman", | |
"Christopher Nolan"); | |
videoteca.addMovie("Superman: The Man of Steel", | |
"Accio", | |
"Millor que la anterior", | |
"Qui sap"); | |
videoteca.addMovie("The Prestige", | |
"Intriga", | |
"Visca la prestidigitacio! Bona peli", | |
"Christopher Nolan"); | |
videoteca.getTitles(); | |
// System.out.println(videoteca.getTitles()); | |
// videoteca.findMovie("Batman", titulo); | |
// videoteca.findMovie("Accio", genero); | |
// videoteca.findMovie("Nolan", director); | |
// </dev> | |
} | |
} | |
class Videoteca { | |
public static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); | |
private ArrayList<Pelicula> videoteca = new ArrayList<Pelicula>(); | |
public void addMovie (String titulo, String genero, String resumen, String director) { | |
this.videoteca.add(new Pelicula(titulo, genero, resumen, director)); | |
} | |
public void getTitles() { | |
for (byte i = 0; i < this.videoteca.size(); i++) { | |
System.out.println(this.videoteca.get(i).getTitle()); | |
} | |
} | |
// public String[][] sortMovies () { | |
// byte current_vote = 0, | |
// max_vote = 0; | |
// movies = String[this.titulos.size()][2]; | |
// for (byte i = 0; i < this.titulos.size(); i++) { | |
// current_vote = this.votos.get(i); | |
// if (current_vote >= max_vote) { | |
// max_vote = current_vote; | |
// } | |
// } | |
// return movies; | |
// } | |
// public void findMovie (String query, Byte queryType) throws IOException { | |
// String input; | |
// query = query.toLowerCase(); | |
// switch (queryType) { | |
// case 0: | |
// byTitle(query); | |
// break; | |
// case 1: | |
// byGenre(query); | |
// break; | |
// case 2: | |
// byDir(query); | |
// break; | |
// default: | |
// byTitle(query); | |
// break; | |
// } | |
// } | |
// public void byTitle (String query) throws IOException { | |
// String input; | |
// for (byte i = 0; i < this.titulos.size(); i++) { | |
// String current_movie = this.titulos.get(i); | |
// int current_vote = this.votos.get(i); | |
// if (current_movie.toLowerCase().contains(query)) { | |
// System.out.println(current_movie); | |
// System.out.println("Would you like to vote for " + current_movie + "? (y/N)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("y")) { | |
// System.out.println("Good or bad? (g/B)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("g")) { | |
// voteFun(i, 1); | |
// } else { | |
// voteFun(i, -1); | |
// } | |
// System.out.println("Vote count for " + current_movie + ": " + this.votos.get(i)); | |
// } | |
// } | |
// } | |
// } | |
// public void byGenre (String query) throws IOException { | |
// String input; | |
// for (byte i = 0; i < this.videoteca.size(); i++) { | |
// String current_movie = this.videoteca.get(i); | |
// int current_vote = this.votos.get(i); | |
// if (current_genre.toLowerCase().contains(query)) { | |
// System.out.println(current_movie); | |
// System.out.println("Would you like to vote for " + current_movie + "? (y/N)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("y")) { | |
// System.out.println("Good or bad? (g/B)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("g")) { | |
// voteFun(i, 1); | |
// } else { | |
// voteFun(i, -1); | |
// } | |
// System.out.println("Vote count for " + current_movie + ": " + this.votos.get(i)); | |
// } | |
// } | |
// } | |
// } | |
// public void byDir (String query) throws IOException { | |
// String input; | |
// for (byte i = 0; i < this.directores.size(); i++) { | |
// String current_movie = this.titulos.get(i), | |
// current_dir = this.directores.get(i); | |
// int current_vote = this.votos.get(i); | |
// if (current_dir.toLowerCase().contains(query)) { | |
// System.out.println(current_movie); | |
// System.out.println("Would you like to vote for " + current_movie + "? (y/N)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("y")) { | |
// System.out.println("Good or bad? (g/B)"); | |
// input = stdin.readLine(); | |
// if (input.toLowerCase().equals("g")) { | |
// voteFun(i, 1); | |
// } else { | |
// voteFun(i, -1); | |
// } | |
// System.out.println("Vote count for " + current_movie + ": " + this.votos.get(i)); | |
// } | |
// } | |
// } | |
// } | |
// public void voteFun (int position, int vote) { | |
// int current_vote = this.votos.get(position); | |
// int new_vote = current_vote + vote; | |
// this.votos.set(position, new_vote); | |
// } | |
// public ArrayList<String> getTitles () { | |
// return this.titulos; | |
// } | |
} | |
class Pelicula { | |
private String titulo; | |
private String genero; | |
private String resumen; | |
private String director; | |
private int votos = 0; | |
public Pelicula (String titulo, String genero, String resumen, String director) { | |
this.titulo = titulo; | |
this.genero = genero; | |
this.resumen = resumen; | |
this.director = director; | |
} | |
public String getTitle () { | |
return this.titulo; | |
} | |
public String getGenre () { | |
return this.genero; | |
} | |
public String getSyn () { | |
return this.resumen; | |
} | |
public String getDir () { | |
return this.director; | |
} | |
public Integer getVotes () { | |
return this.votos; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment