diff --git a/AmazonViewer/.classpath b/AmazonViewer/.classpath
new file mode 100644
index 0000000..84c8c89
--- /dev/null
+++ b/AmazonViewer/.classpath
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AmazonViewer/.project b/AmazonViewer/.project
new file mode 100644
index 0000000..b9f7f63
--- /dev/null
+++ b/AmazonViewer/.project
@@ -0,0 +1,17 @@
+
+
+ AmazonViewer
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/AmazonViewer/.settings/org.eclipse.jdt.core.prefs b/AmazonViewer/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..7e5c907
--- /dev/null
+++ b/AmazonViewer/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=9
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=9
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=9
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/Main.class b/AmazonViewer/bin/com/anncode/amazonviewer/Main.class
new file mode 100644
index 0000000..8586384
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/Main.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/dao/MovieDAO.class b/AmazonViewer/bin/com/anncode/amazonviewer/dao/MovieDAO.class
new file mode 100644
index 0000000..e29720e
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/dao/MovieDAO.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/db/DataBase.class b/AmazonViewer/bin/com/anncode/amazonviewer/db/DataBase.class
new file mode 100644
index 0000000..300db32
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/db/DataBase.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/db/IDBConnection.class b/AmazonViewer/bin/com/anncode/amazonviewer/db/IDBConnection.class
new file mode 100644
index 0000000..51f3214
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/db/IDBConnection.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Book$Page.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Book$Page.class
new file mode 100644
index 0000000..1909748
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Book$Page.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Book.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Book.class
new file mode 100644
index 0000000..00418ab
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Book.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Chapter.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Chapter.class
new file mode 100644
index 0000000..be85393
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Chapter.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Film.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Film.class
new file mode 100644
index 0000000..675c026
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Film.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/IVisualizable.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/IVisualizable.class
new file mode 100644
index 0000000..e96d32c
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/IVisualizable.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Magazine.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Magazine.class
new file mode 100644
index 0000000..4ce039f
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Magazine.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Movie.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Movie.class
new file mode 100644
index 0000000..5510d59
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Movie.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Publication.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Publication.class
new file mode 100644
index 0000000..e8a8450
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Publication.class differ
diff --git a/AmazonViewer/bin/com/anncode/amazonviewer/model/Serie.class b/AmazonViewer/bin/com/anncode/amazonviewer/model/Serie.class
new file mode 100644
index 0000000..6124ec9
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/amazonviewer/model/Serie.class differ
diff --git a/AmazonViewer/bin/com/anncode/util/AmazonUtil.class b/AmazonViewer/bin/com/anncode/util/AmazonUtil.class
new file mode 100644
index 0000000..0e26b87
Binary files /dev/null and b/AmazonViewer/bin/com/anncode/util/AmazonUtil.class differ
diff --git a/AmazonViewer/libs/makefile.jar b/AmazonViewer/libs/makefile.jar
new file mode 100644
index 0000000..fe69534
Binary files /dev/null and b/AmazonViewer/libs/makefile.jar differ
diff --git a/AmazonViewer/libs/mysql-connector-java-5.1.46.jar b/AmazonViewer/libs/mysql-connector-java-5.1.46.jar
new file mode 100644
index 0000000..6d26d72
Binary files /dev/null and b/AmazonViewer/libs/mysql-connector-java-5.1.46.jar differ
diff --git a/AmazonViewer/reporte.txt b/AmazonViewer/reporte.txt
new file mode 100644
index 0000000..3f9d8d1
--- /dev/null
+++ b/AmazonViewer/reporte.txt
@@ -0,0 +1,21 @@
+
+ :: MOVIE ::
+ Title: Coco
+ Genero: Animación
+ Year: 2017
+ Creator: Pixart
+ Duration: 120
+
+ :: MOVIE ::
+ Title: Titanic
+ Genero: Drama
+ Year: 1997
+ Creator: James Cameron
+ Duration: 195
+
+ :: MOVIE ::
+ Title: Amélie
+ Genero: Romance
+ Year: 2001
+ Creator: Jean-Pierre Jeunet
+ Duration: 123
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/Main.java b/AmazonViewer/src/com/anncode/amazonviewer/Main.java
new file mode 100644
index 0000000..b428120
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/Main.java
@@ -0,0 +1,351 @@
+package com.anncode.amazonviewer;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Scanner;
+
+import com.anncode.amazonviewer.model.Book;
+import com.anncode.amazonviewer.model.Chapter;
+import com.anncode.amazonviewer.model.Film;
+import com.anncode.amazonviewer.model.Magazine;
+import com.anncode.amazonviewer.model.Movie;
+import com.anncode.amazonviewer.model.Serie;
+import com.anncode.makereport.Report;
+import com.anncode.util.AmazonUtil;
+
+
+
+/**
+ *
AmazonViewer
+ * AmazonViewer es un programa que permite visualizar Movies, Series con sus respectivos Chapters,
+ * Books y Magazines. Te permite generar reportes generales y con fecha del día.
+ *
+ * Existen algunas reglas como que todos los elementos pueden ser visualizadors o leídos a excepción
+ * de las Magazines, estás solo pueden ser vistas a modo de exposición sin ser leídas.
+ *
+ * @author anncode
+ * @version 1.1
+ * @since 2018
+ *
+ * */
+public class Main {
+
+ public static void main(String[] args) {
+ // TODO Auto-generated method stub
+ showMenu();
+
+ }
+
+ public static void showMenu() {
+ int exit = 0;
+ do {
+
+ System.out.println("BIENVENIDOS AMAZON VIEWER");
+ System.out.println("");
+ System.out.println("Selecciona el número de la opción deseada");
+ System.out.println("1. Movies");
+ System.out.println("2. Series");
+ System.out.println("3. Books");
+ System.out.println("4. Magazines");
+ System.out.println("5. Report");
+ System.out.println("6. Report Today");
+ System.out.println("0. Exit");
+
+ //Leer la respuesta del usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, 6);
+
+ switch (response) {
+ case 0:
+ //salir
+ exit = 0;
+ break;
+ case 1:
+ showMovies();
+ break;
+ case 2:
+ showSeries();
+ break;
+ case 3:
+ showBooks();
+ break;
+ case 4:
+ showMagazines();
+ break;
+ case 5:
+ makeReport();
+ exit = 1;
+ break;
+ case 6:
+ //Date date = new Date();
+ makeReport(new Date());
+ exit = 1;
+ break;
+
+ default:
+ System.out.println();
+ System.out.println("....¡¡Selecciona una opción!!....");
+ System.out.println();
+ exit = 1;
+ break;
+ }
+
+
+ }while(exit != 0);
+ }
+
+ static ArrayList movies = new ArrayList();
+ public static void showMovies() {
+ movies = Movie.makeMoviesList();
+ int exit = 1;
+
+ do {
+ System.out.println();
+ System.out.println(":: MOVIES ::");
+ System.out.println();
+
+ for (int i = 0; i < movies.size(); i++) { //1. Movie 1
+ System.out.println(i+1 + ". " + movies.get(i).getTitle() + " Visto: " + movies.get(i).isViewed());
+ }
+
+ System.out.println("0. Regresar al Menu");
+ System.out.println();
+
+ //Leer Respuesta usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, movies.size());
+
+ if(response == 0) {
+ exit = 0;
+ showMenu();
+ break;
+ }
+ if (response > 0) {
+ Movie movieSelected = movies.get(response-1);
+ movieSelected.view();
+ }
+
+
+ }while(exit !=0);
+
+ }
+ static ArrayList series = Serie.makeSeriesList();
+ public static void showSeries() {
+ int exit = 1;
+
+ do {
+ System.out.println();
+ System.out.println(":: SERIES ::");
+ System.out.println();
+
+ for (int i = 0; i < series.size(); i++) { //1. Serie 1
+ System.out.println(i+1 + ". " + series.get(i).getTitle() + " Visto: " + series.get(i).isViewed());
+ }
+
+ System.out.println("0. Regresar al Menu");
+ System.out.println();
+
+ //Leer Respuesta usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, series.size());
+
+ if(response == 0) {
+ exit = 0;
+ showMenu();
+ }
+
+ if(response > 0) {
+ showChapters(series.get(response-1).getChapters());
+ }
+
+
+ }while(exit !=0);
+ }
+
+ public static void showChapters(ArrayList chaptersOfSerieSelected) {
+ int exit = 1;
+
+ do {
+ System.out.println();
+ System.out.println(":: CHAPTERS ::");
+ System.out.println();
+
+
+ for (int i = 0; i < chaptersOfSerieSelected.size(); i++) { //1. Chapter 1
+ System.out.println(i+1 + ". " + chaptersOfSerieSelected.get(i).getTitle() + " Visto: " + chaptersOfSerieSelected.get(i).isViewed());
+ }
+
+ System.out.println("0. Regresar al Menu");
+ System.out.println();
+
+ //Leer Respuesta usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, chaptersOfSerieSelected.size());
+
+ if(response == 0) {
+ exit = 0;
+ }
+
+
+ if(response > 0) {
+ Chapter chapterSelected = chaptersOfSerieSelected.get(response-1);
+ chapterSelected.view();
+ }
+ }while(exit !=0);
+ }
+
+ static ArrayList books= Book.makeBookList();
+ public static void showBooks() {
+ int exit = 1;
+
+ do {
+ System.out.println();
+ System.out.println(":: BOOKS ::");
+ System.out.println();
+
+ for (int i = 0; i < books.size(); i++) { //1. Book 1
+ System.out.println(i+1 + ". " + books.get(i).getTitle() + " Leído: " + books.get(i).isReaded());
+ }
+
+ System.out.println("0. Regresar al Menu");
+ System.out.println();
+
+ //Leer Respuesta usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, books.size());
+
+ if(response == 0) {
+ exit = 0;
+ showMenu();
+ }
+
+ if(response > 0) {
+ Book bookSelected = books.get(response-1);
+ bookSelected.view();
+ }
+
+ }while(exit !=0);
+ }
+
+ public static void showMagazines() {
+ ArrayList magazines = Magazine.makeMagazineList();
+ int exit = 0;
+ do {
+ System.out.println();
+ System.out.println(":: MAGAZINES ::");
+ System.out.println();
+
+ for (int i = 0; i < magazines.size(); i++) { //1. Book 1
+ System.out.println(i+1 + ". " + magazines.get(i).getTitle());
+ }
+
+ System.out.println("0. Regresar al Menu");
+ System.out.println();
+
+ //Leer Respuesta usuario
+ int response = AmazonUtil.validateUserResponseMenu(0, 0);
+
+ if(response == 0) {
+ exit = 0;
+ showMenu();
+ }
+
+
+ }while(exit !=0);
+ }
+
+ public static void makeReport() {
+
+ Report report = new Report();
+ report.setNameFile("reporte");
+ report.setExtension("txt");
+ report.setTitle(":: VISTOS ::");
+ String contentReport = "";
+
+ for (Movie movie : movies) {
+ if (movie.getIsViewed()) {
+ contentReport += movie.toString() + "\n";
+
+ }
+ }
+
+ for (Serie serie : series) {
+ ArrayList chapters = serie.getChapters();
+ for (Chapter chapter : chapters) {
+ if (chapter.getIsViewed()) {
+ contentReport += chapter.toString() + "\n";
+
+ }
+ }
+ }
+
+
+ for (Book book : books) {
+ if (book.getIsReaded()) {
+ contentReport += book.toString() + "\n";
+
+ }
+ }
+
+ report.setContent(contentReport);
+ report.makeReport();
+ System.out.println("Reporte Generado");
+ System.out.println();
+ }
+
+ public static void makeReport(Date date) {
+ SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd-h-m-s-S");
+ String dateString = df.format(date);
+ Report report = new Report();
+
+ report.setNameFile("reporte" + dateString);
+ report.setExtension("txt");
+ report.setTitle(":: VISTOS ::");
+
+
+ SimpleDateFormat dfNameDays = new SimpleDateFormat("E, W MMM Y");
+ dateString = dfNameDays.format(date);
+ String contentReport = "Date: " + dateString + "\n\n\n";
+
+ for (Movie movie : movies) {
+ if (movie.getIsViewed()) {
+ contentReport += movie.toString() + "\n";
+
+ }
+ }
+
+ for (Serie serie : series) {
+ ArrayList chapters = serie.getChapters();
+ for (Chapter chapter : chapters) {
+ if (chapter.getIsViewed()) {
+ contentReport += chapter.toString() + "\n";
+
+ }
+ }
+ }
+
+ for (Book book : books) {
+ if (book.getIsReaded()) {
+ contentReport += book.toString() + "\n";
+
+ }
+ }
+ report.setContent(contentReport);
+ report.makeReport();
+
+ System.out.println("Reporte Generado");
+ System.out.println();
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/dao/MovieDAO.java b/AmazonViewer/src/com/anncode/amazonviewer/dao/MovieDAO.java
new file mode 100644
index 0000000..2a6a9eb
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/dao/MovieDAO.java
@@ -0,0 +1,103 @@
+package com.anncode.amazonviewer.dao;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import static com.anncode.amazonviewer.db.DataBase.*;
+
+import com.anncode.amazonviewer.db.IDBConnection;
+import com.anncode.amazonviewer.model.Movie;
+
+public interface MovieDAO extends IDBConnection {
+
+ default Movie setMovieViewed(Movie movie) {
+ try(Connection connection = connectToDB()){
+ Statement statement = connection.createStatement();
+ String query = "INSERT INTO " + TVIEWED +
+ " ("+TVIEWED_IDMATERIAL+", "+TVIEWED_IDELEMENT+", "+TVIEWED_IDUSUARIO+")" +
+ " VALUES("+ID_TMATERIALS [0]+", "+movie.getId()+", "+TUSER_IDUSUARIO+")";
+ if (statement.executeUpdate(query) > 0) {
+ System.out.println("Se marcó en Visto");
+ }
+
+
+ }catch(SQLException e) {
+ e.printStackTrace();
+ }
+
+ return movie;
+ }
+
+ default ArrayList read(){
+ ArrayList movies = new ArrayList();
+ try (Connection connection = connectToDB()){
+ String query = "SELECT * FROM " + TMOVIE;
+ PreparedStatement preparedStatement = connection.prepareStatement(query);
+ ResultSet rs = preparedStatement.executeQuery();
+
+ while (rs.next()) {
+ Movie movie = new Movie(
+ rs.getString(TMOVIE_TITLE),
+ rs.getString(TMOVIE_GENRE),
+ rs.getString(TMOVIE_CREATOR),
+ Integer.valueOf(rs.getString(TMOVIE_DURATION)),
+ Short.valueOf(rs.getString(TMOVIE_YEAR)));
+
+ movie.setId(Integer.valueOf(rs.getString(TMOVIE_ID)));
+ movie.setViewed(getMovieViewed(
+ preparedStatement,
+ connection,
+ Integer.valueOf(rs.getString(TMOVIE_ID))));
+ movies.add(movie);
+
+ }
+
+
+ }catch (SQLException e) {
+ // TODO: handle exception
+ }
+ return movies;
+ }
+
+ private boolean getMovieViewed(PreparedStatement preparedStatement, Connection connection, int id_movie) {
+ boolean viewed = false;
+ String query = "SELECT * FROM " + TVIEWED +
+ " WHERE " + TVIEWED_IDMATERIAL + "= ?"+
+ " AND " + TVIEWED_IDELEMENT + "= ?" +
+ " AND " + TVIEWED_IDUSUARIO + "= ?";
+ ResultSet rs = null;
+
+ try {
+ preparedStatement = connection.prepareStatement(query);
+ preparedStatement.setInt(1, ID_TMATERIALS[0]);
+ preparedStatement.setInt(2, id_movie);
+ preparedStatement.setInt(3, TUSER_IDUSUARIO);
+
+ rs = preparedStatement.executeQuery();
+ viewed = rs.next();
+
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }
+
+
+ return viewed;
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/db/DataBase.java b/AmazonViewer/src/com/anncode/amazonviewer/db/DataBase.java
new file mode 100644
index 0000000..4919c36
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/db/DataBase.java
@@ -0,0 +1,33 @@
+package com.anncode.amazonviewer.db;
+
+public class DataBase {
+
+ public static final String URL = "jdbc:mysql://localhost:3306/";
+ public static final String DB = "amazonviewer";
+ public static final String USER = "amazonviewer";
+ public static final String PASSWORD = "amazonviewer";
+
+ public static final String TMOVIE = "movie";
+ public static final String TMOVIE_ID = "id";
+ public static final String TMOVIE_TITLE = "title";
+ public static final String TMOVIE_GENRE = "genre";
+ public static final String TMOVIE_CREATOR = "creator";
+ public static final String TMOVIE_DURATION = "duration";
+ public static final String TMOVIE_YEAR = "year";
+
+
+ public static final String TMATERIAL = "material";
+ public static final int[] ID_TMATERIALS = {1,2,3,4,5};
+
+ public static final String TUSER = "user";
+ public static final int TUSER_IDUSUARIO = 1;
+
+ public static final String TVIEWED = "viewed";
+ public static final String TVIEWED_IDMATERIAL = "id_material";
+ public static final String TVIEWED_IDELEMENT = "id_element";
+ public static final String TVIEWED_IDUSUARIO = "id_user";
+
+}
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/db/IDBConnection.java b/AmazonViewer/src/com/anncode/amazonviewer/db/IDBConnection.java
new file mode 100644
index 0000000..a221a43
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/db/IDBConnection.java
@@ -0,0 +1,27 @@
+package com.anncode.amazonviewer.db;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import static com.anncode.amazonviewer.db.DataBase.*;
+
+public interface IDBConnection {
+
+ default Connection connectToDB() {
+ Connection connection = null;
+
+ try {
+ Class.forName("com.mysql.jdbc.Driver");
+ connection = DriverManager.getConnection(URL+DB, USER, PASSWORD);
+ if (connection != null) {
+ System.out.println("Se estableció la conexión :)");
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ e.printStackTrace();
+ }finally {
+ return connection;
+ }
+
+ }
+
+}
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Book.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Book.java
new file mode 100644
index 0000000..fc71a3b
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Book.java
@@ -0,0 +1,220 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import com.anncode.util.AmazonUtil;
+
+public class Book extends Publication implements IVisualizable {
+ private int id;
+ private String isbn;
+ private boolean readed;
+ private int timeReaded;
+ private ArrayList pages;
+
+
+
+ public Book(String title, Date edititionDate, String editorial, String[] authors, ArrayList pages) {
+ super(title, edititionDate, editorial);
+ // TODO Auto-generated constructor stub
+ setAuthors(authors);
+ this.pages = pages;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+
+ public String getIsbn() {
+ return isbn;
+ }
+
+
+ public void setIsbn(String isbn) {
+ this.isbn = isbn;
+ }
+
+
+ public String isReaded() {
+ String leido = "";
+ if(readed == true) {
+ leido = "Sí";
+ }else {
+ leido = "No";
+ }
+
+ return leido;
+ }
+
+
+ public void setReaded(boolean readed) {
+ this.readed = readed;
+ }
+
+ public boolean getIsReaded() {
+ return readed;
+ }
+
+
+ public int getTimeReaded() {
+ return timeReaded;
+ }
+
+
+ public void setTimeReaded(int timeReaded) {
+ this.timeReaded = timeReaded;
+ }
+
+ @Override
+ public String toString() {
+ // TODO Auto-generated method stub
+ String detailBook = "\n :: BOOK ::" +
+ "\n Title: " + getTitle() +
+ "\n Editorial: " + getEditorial() +
+ "\n Edition Date: " + getEdititionDate() +
+ "\n Authors: ";
+ for (int i = 0; i < getAuthors().length; i++) {
+ detailBook += "\t" + getAuthors()[i] + " ";
+ }
+ return detailBook;
+ }
+
+
+ @Override
+ public Date startToSee(Date dateI) {
+ // TODO Auto-generated method stub
+ return dateI;
+ }
+
+
+ @Override
+ public void stopToSee(Date dateI, Date dateF) {
+ // TODO Auto-generated method stub
+ if (dateF.getTime() > dateI.getTime()) {
+ setTimeReaded((int)(dateF.getTime() - dateI.getTime()));
+ }else {
+ setTimeReaded(0);
+ }
+ }
+
+ public void view() {
+ setReaded(true);
+ Date dateI = startToSee(new Date());
+
+
+ int i = 0;
+ do {
+ System.out.println("..........");
+ System.out.println("Page " + getPages().get(i).getNumber());
+ System.out.println(getPages().get(i).getContent());
+ System.out.println("..........");
+
+ if (i != 0) {
+ System.out.println("1. Regresar Página");
+ }
+
+ System.out.println("2. Siguiente Página");
+ System.out.println("0. Cerrar Libro");
+ System.out.println();
+
+ int response = AmazonUtil.validateUserResponseMenu(0, 2);
+
+ if (response == 2) {
+ i++;
+ }else if(response == 1) {
+ i--;
+ }else if(response == 0) {
+ break;
+ }
+
+ }while(i < getPages().size());
+
+
+ //Termine de verla
+ stopToSee(dateI, new Date());
+ System.out.println();
+ System.out.println("Leíste: " + toString());
+ System.out.println("Por: " + getTimeReaded() + " milisegundos");
+ }
+
+ public static ArrayList makeBookList() {
+ ArrayList books = new ArrayList();
+ String[] authors = new String[3];
+ for (int i = 0; i < 3; i++) {
+ authors[i] = "author "+i;
+ }
+
+ ArrayList pages = new ArrayList();
+ int pagina = 0;
+ for (int i = 0; i < 3; i++) {
+ pagina = i+1;
+ pages.add(new Book.Page(pagina, "El contenido de la página " + pagina));
+ }
+
+ for (int i = 1; i <= 5; i++) {
+ books.add(new Book("Book " + i, new Date(), "editorial " + i, authors, pages));
+ }
+
+ return books;
+ }
+
+
+ public ArrayList getPages() {
+ return pages;
+ }
+
+
+ public void setPages(ArrayList pages) {
+ this.pages = pages;
+ }
+
+
+ public static class Page {
+ private int id;
+ private int number;
+ private String content;
+
+ public Page(int number, String content) {
+ super();
+ this.number = number;
+ this.content = content;
+ }
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+ public int getNumber() {
+ return number;
+ }
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ public String getContent() {
+ return content;
+ }
+ public void setContent(String content) {
+ this.content = content;
+ }
+
+
+
+
+ }
+
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Chapter.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Chapter.java
new file mode 100644
index 0000000..618547f
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Chapter.java
@@ -0,0 +1,93 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.ArrayList;
+
+/**
+ * Hereda de {@link Movie}
+ * @see Film
+ * */
+public class Chapter extends Movie {
+
+
+ private int id;
+ private int sessionNumber;
+ private Serie serie;
+
+ public Chapter(String title, String genre, String creator, int duration, short year, int sessionNumber, Serie serie) {
+ super(title, genre, creator, duration, year);
+ // TODO Auto-generated constructor stub
+ this.setSessionNumber(sessionNumber);
+ this.setSerie(serie);
+ }
+
+ @Override
+ public int getId() {
+ // TODO Auto-generated method stub
+ return this.id;
+ }
+
+ public int getSessionNumber() {
+ return sessionNumber;
+ }
+
+ public void setSessionNumber(int sessionNumber) {
+ this.sessionNumber = sessionNumber;
+ }
+
+
+ public Serie getSerie() {
+ return serie;
+ }
+
+ public void setSerie(Serie serie) {
+ this.serie = serie;
+ }
+
+ @Override
+ public String toString() {
+ // TODO Auto-generated method stub
+ return "\n :: SERIE ::" +
+ "\n Title: " + getSerie().getTitle() +
+ "\n :: CHAPTER ::" +
+ "\n Title: " + getTitle() +
+ "\n Year: " + getYear() +
+ "\n Creator: " + getCreator() +
+ "\n Duration: " + getDuration();
+ }
+
+
+ public static ArrayList makeChaptersList(Serie serie) {
+ ArrayList chapters = new ArrayList();
+
+ for (int i = 1; i <= 5; i++) {
+ chapters.add(new Chapter("Capituo "+i, "genero "+i, "creator" +i, 45, (short)(2017+i), i, serie));
+ }
+
+ return chapters;
+ }
+
+ @Override
+ public void view() {
+ // TODO Auto-generated method stub
+ super.view();
+ ArrayList chapters = getSerie().getChapters();
+ int chapterViewedCounter = 0;
+ for (Chapter chapter : chapters) {
+ if (chapter.getIsViewed()) {
+ chapterViewedCounter++;
+ }
+ }
+
+ if (chapterViewedCounter == chapters.size()) {
+ getSerie().view();
+ }
+ }
+
+}
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Film.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Film.java
new file mode 100644
index 0000000..51ec917
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Film.java
@@ -0,0 +1,98 @@
+package com.anncode.amazonviewer.model;
+
+
+/**
+ * Film
+ * Film es una clase padre abstracta
+ *
+ * Esta clase es la clase base de la familia Films, como es abstracta
+ * no pueden crearse instancias. Continene el método abstracto
+ * {@code view()} que es obligatorio implementar para todo aquél que pertenezca a la familia.
+ *
+ *
+ * @author anncode
+ * @version 1.1
+ * @since 2018
+ * */
+public abstract class Film {
+
+ private String title;
+ private String genre;
+ private String creator;
+ private int duration;
+ private short year;
+ private boolean viewed;
+
+
+ public Film() {}
+ public Film(String title, String genre, String creator, int duration) {
+ super();
+ this.title = title;
+ this.genre = genre;
+ this.creator = creator;
+ this.duration = duration;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public String getGenre() {
+ return genre;
+ }
+ public void setGenre(String genre) {
+ this.genre = genre;
+ }
+ public String getCreator() {
+ return creator;
+ }
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+ public int getDuration() {
+ return duration;
+ }
+ public void setDuration(int duration) {
+ this.duration = duration;
+ }
+ public short getYear() {
+ return year;
+ }
+ public void setYear(short year) {
+ this.year = year;
+ }
+ public String isViewed() {
+ String visto = "";
+ if(viewed == true) {
+ visto = "Sí";
+ }else {
+ visto = "No";
+ }
+
+ return visto;
+ }
+
+ public boolean getIsViewed() {
+ return viewed;
+ }
+ public void setViewed(boolean viewed) {
+ this.viewed = viewed;
+ }
+
+ /**
+ * {@code view()} es un método abstracto obligatorio de implementar
+ * */
+ public abstract void view();
+
+}
+
+
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/IVisualizable.java b/AmazonViewer/src/com/anncode/amazonviewer/model/IVisualizable.java
new file mode 100644
index 0000000..d335559
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/IVisualizable.java
@@ -0,0 +1,24 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.Date;
+
+public interface IVisualizable {
+
+ /**
+ * Este método captura el tiempo exacto de inicio de visualización
+ *
+ * @param dateI Es un objeto {@code Date} con el tiempo de inicio exacto.
+ * @return Devuelve la fecha y hora capturada
+ * */
+ Date startToSee(Date dateI);
+
+
+ /**
+ * Este método captura el tiempo exacto de inicio y final de visualización
+ *
+ * @param dateI Es un objeto {@code Date} con el tiempo de inicio exacto.
+ * @param dateF Es un objeto {@code Date} con el tiempo de final exacto.
+ * */
+ void stopToSee(Date dateI, Date dateF);
+
+}
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Magazine.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Magazine.java
new file mode 100644
index 0000000..e71ec0c
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Magazine.java
@@ -0,0 +1,46 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+public class Magazine extends Publication {
+
+ private int id;
+
+ public Magazine(String title, Date edititionDate, String editorial) {
+ super(title, edititionDate, editorial);
+ // TODO Auto-generated constructor stub
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ // TODO Auto-generated method stub
+ String detailMagazine = "\n :: MAGAZINE ::" +
+ "\n Title: " + getTitle() +
+ "\n Editorial: " + getEditorial() +
+ "\n Edition Date: " + getEdititionDate() +
+ "\n Authors: ";
+ for (int i = 0; i < getAuthors().length; i++) {
+ detailMagazine += "\t" + getAuthors()[i] + " ";
+ }
+ return detailMagazine;
+ }
+
+ public static ArrayList makeMagazineList() {
+ ArrayList magazines = new ArrayList();
+ String[] authors = new String[3];
+ for (int i = 0; i < 3; i++) {
+ authors[i] = "author "+i;
+ }
+ for (int i = 1; i <= 5; i++) {
+ magazines.add(new Magazine("Magazine " + i, new Date(), "Editorial " + i));
+ }
+
+ return magazines;
+ }
+
+}
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Movie.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Movie.java
new file mode 100644
index 0000000..6ec3c7c
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Movie.java
@@ -0,0 +1,112 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.ArrayList;
+import java.util.Date;
+
+import com.anncode.amazonviewer.dao.MovieDAO;
+
+/**
+ * Hereda de {@link Film}
+ * Implementea de {@link IVisualizable}
+ * */
+public class Movie extends Film implements IVisualizable, MovieDAO {
+
+ private int id;
+ private int timeViewed;
+
+ public Movie() {
+
+ }
+ public Movie(String title, String genre, String creator, int duration, short year) {
+ super(title, genre, creator, duration);
+ setYear(year);
+ }
+
+
+ public int getId() {
+ return id;
+ }
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getTimeViewed() {
+ return timeViewed;
+ }
+ public void setTimeViewed(int timeViewed) {
+ this.timeViewed = timeViewed;
+ }
+
+ @Override
+ public String toString() {
+ // TODO Auto-generated method stub
+ return "\n :: MOVIE ::" +
+ "\n Title: " + getTitle() +
+ "\n Genero: " + getGenre() +
+ "\n Year: " + getYear() +
+ "\n Creator: " + getCreator() +
+ "\n Duration: " + getDuration();
+ }
+
+ /**
+ * {@inheritDoc}
+ * */
+ @Override
+ public Date startToSee(Date dateI) {
+ // TODO Auto-generated method stub
+ return dateI;
+ }
+
+ /**
+ * {@inheritDoc}
+ * */
+ @Override
+ public void stopToSee(Date dateI, Date dateF) {
+ // TODO Auto-generated method stub
+
+ if (dateF.getTime() > dateI.getTime()) {
+ setTimeViewed((int)(dateF.getTime() - dateI.getTime()));
+ }else {
+ setTimeViewed(0);
+ }
+
+
+ }
+
+ public static ArrayList makeMoviesList() {
+ Movie movie = new Movie();
+ return movie.read();
+ }
+
+ /**
+ * {@inheritDoc}
+ * */
+ @Override
+ public void view() {
+ // TODO Auto-generated method stub
+ setViewed(true);
+ Movie movie = new Movie();
+ movie.setMovieViewed(this);
+
+ Date dateI = startToSee(new Date());
+
+
+ for (int i = 0; i < 100000; i++) {
+ System.out.println("..........");
+ }
+
+ //Termine de verla
+ stopToSee(dateI, new Date());
+ System.out.println();
+ System.out.println("Viste: " + toString());
+ System.out.println("Por: " + getTimeViewed() + " milisegundos");
+ }
+
+}
+
+
+
+
+
+
+
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Publication.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Publication.java
new file mode 100644
index 0000000..22d2322
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Publication.java
@@ -0,0 +1,48 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.Date;
+
+public class Publication {
+
+ private String title;
+ private Date edititionDate;
+ private String editorial;
+ private String[] authors;
+
+
+ public Publication(String title, Date edititionDate, String editorial) {
+ super();
+ this.title = title;
+ this.edititionDate = edititionDate;
+ this.editorial = editorial;
+ }
+
+
+ public String getTitle() {
+ return title;
+ }
+ public void setTitle(String title) {
+ this.title = title;
+ }
+ public Date getEdititionDate() {
+ return edititionDate;
+ }
+ public void setEdititionDate(Date edititionDate) {
+ this.edititionDate = edititionDate;
+ }
+ public String getEditorial() {
+ return editorial;
+ }
+ public void setEditorial(String editorial) {
+ this.editorial = editorial;
+ }
+ public String[] getAuthors() {
+ return authors;
+ }
+ public void setAuthors(String[] authors) {
+ this.authors = authors;
+ }
+
+
+
+}
diff --git a/AmazonViewer/src/com/anncode/amazonviewer/model/Serie.java b/AmazonViewer/src/com/anncode/amazonviewer/model/Serie.java
new file mode 100644
index 0000000..d134ad3
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/amazonviewer/model/Serie.java
@@ -0,0 +1,72 @@
+package com.anncode.amazonviewer.model;
+
+import java.util.ArrayList;
+
+public class Serie extends Film {
+
+ private int id;
+ private int sessionQuantity;
+ private ArrayList chapters;
+
+
+ public Serie(String title, String genre, String creator, int duration, int sessionQuantity) {
+ super(title, genre, creator, duration);
+ // TODO Auto-generated constructor stub
+ this.sessionQuantity = sessionQuantity;
+ }
+
+
+
+ public int getId() {
+ return id;
+ }
+
+ public int getSessionQuantity() {
+ return sessionQuantity;
+ }
+
+ public void setSessionQuantity(int sessionQuantity) {
+ this.sessionQuantity = sessionQuantity;
+ }
+
+ public ArrayList getChapters() {
+ return chapters;
+ }
+
+ public void setChapters(ArrayList chapters) {
+ this.chapters = chapters;
+ }
+
+ @Override
+ public String toString() {
+ // TODO Auto-generated method stub
+ return "\n :: SERIE ::" +
+ "\n Title: " + getTitle() +
+ "\n Genero: " + getGenre() +
+ "\n Year: " + getYear() +
+ "\n Creator: " + getCreator() +
+ "\n Duration: " + getDuration();
+ }
+
+ public static ArrayList makeSeriesList() {
+ ArrayList series = new ArrayList();
+
+ for (int i = 1; i <= 5; i++) {
+ Serie serie = new Serie("Serie "+i, "genero "+i, "creador "+i, 1200, 5);
+ serie.setChapters(Chapter.makeChaptersList(serie));
+ series.add(serie);
+
+ }
+
+ return series;
+ }
+
+
+
+ @Override
+ public void view() {
+ // TODO Auto-generated method stub
+ setViewed(true);
+ }
+
+}
diff --git a/AmazonViewer/src/com/anncode/util/AmazonUtil.java b/AmazonViewer/src/com/anncode/util/AmazonUtil.java
new file mode 100644
index 0000000..d82107e
--- /dev/null
+++ b/AmazonViewer/src/com/anncode/util/AmazonUtil.java
@@ -0,0 +1,37 @@
+package com.anncode.util;
+
+import java.util.Scanner;
+
+public class AmazonUtil {
+
+ public static int validateUserResponseMenu(int min, int max) {
+ //Leer la respuesta del usuario
+ Scanner sc = new Scanner(System.in);
+
+ //Validar respuesta int
+ while(!sc.hasNextInt()) {
+ sc.next();
+ System.out.println("No ingresaste una opción válida1");
+ System.out.println("Intenta otra vez1");
+ }
+
+ int response = sc.nextInt();
+
+ //Validar rango de respuesta
+ while(response < min || response > max) {
+ //Solicitar de nuevo la respuesta
+ System.out.println("No ingresaste una opción válida");
+ System.out.println("Intenta otra vez");
+
+ while(!sc.hasNextInt()) {
+ sc.next();
+ System.out.println("No ingresaste una opción válida");
+ System.out.println("Intenta otra vez");
+ }
+ response = sc.nextInt();
+ }
+ System.out.println("Tu Respuesta fue: " + response + "\n");
+ return response;
+ }
+
+}
diff --git a/HolaMundo/HolaMundo.class b/HolaMundo/HolaMundo.class
deleted file mode 100644
index 24cda32..0000000
Binary files a/HolaMundo/HolaMundo.class and /dev/null differ
diff --git a/HolaMundo/HolaMundo.java b/HolaMundo/HolaMundo.java
deleted file mode 100644
index 436cd23..0000000
--- a/HolaMundo/HolaMundo.java
+++ /dev/null
@@ -1,5 +0,0 @@
-public class HolaMundo {
- public static void main(String[] args){
- System.out.println("Hola Mundo :)");
- }
-}
\ No newline at end of file