Clase Main.java En esta opcion tengo un poco de duda acerca de asignar una fecha a una variable <strong>tipo date</strong> si alguien tu...

Pregunta de la clase:
Aplicando Herencia (Reto)
Silvia Rodriguez

Silvia Rodriguez

Pregunta
studenthace 6 años

Clase Main.java

MAIN.png

En esta opcion tengo un poco de duda acerca de asignar una fecha a una variable tipo date si alguien tuvo este problema. por ahora solo imprimo la hora actual, lo cual no debe ser, me falta solucionar esa parte si alguien ya soluciono?

esto muestra por consola.

CONSOLA.png

SIGUE

SERIES.png

public class Publication { private String title; private Date editionDate; private String editoral; private String[] authors; public Publication(String title, Date editionDate, String editoral, String[] authors) { super(); this.title = title; this.editionDate = editionDate; this.editoral = editoral; this.authors = authors; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public Date getEditionDate() { return editionDate; } public void setEditionDate(Date editionDate) { this.editionDate = editionDate; } public String getEditoral() { return editoral; } public void setEditoral(String editoral) { this.editoral = editoral; } public String[] getAuthors() { return authors; } public void setAuthors(String[] authors) { this.authors = authors; } }

Clase Book

import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.Iterator; public class Book extends Publication { private int id; private String isbn; private boolean readed; private int timeReaded; public Book(String title, Date editionDate, String editoral, String[] authors,String isbn, boolean readed,int timeReaded) { super(title, editionDate, editoral, authors); this.isbn=isbn; this.readed=readed; this.timeReaded=timeReaded; // TODO Auto-generated constructor stub } public String getIsbn() { return isbn; } public void setIsbn(String isbn) { this.isbn = isbn; } public boolean isReaded() { return readed; } public void setReaded(boolean readed) { this.readed = readed; } public int getTimeReaded() { return timeReaded; } public void setTimeReaded(int timeReaded) { this.timeReaded = timeReaded; } public int getId() { return id; } @Override public String toString() { // TODO Auto-generated method stub return "\n Title: "+getTitle()+"\n Edition Date: "+ new SimpleDateFormat("dd/MM/yyyy").format(getEditionDate())+ "\n Authors: "+Arrays.toString(getAuthors())+"\n Editoral: "+getEditoral()+ "\n Isbn: "+ getIsbn()+"\n Time Read: "+getTimeReaded(); } }

Clase Chapter

public class Chapter extends Movie { private int id; private int sessionNumber; public Chapter(String title, String genre, String creator, int duration, short year, int sessionNumber ) { super(title, genre, creator, duration, year); this.sessionNumber=sessionNumber; // TODO Auto-generated constructor stub } @Override public int getId() { // TODO Auto-generated method stub return this.getId(); } public int getSessionNumber() { return sessionNumber; } public void setSessionNumber(int sessionNumber) { this.sessionNumber = sessionNumber; } @Override public String toString() { // TODO Auto-generated method stub return "\n Title: "+getTitle()+"\n Duration:"+getDuration()+" min."+ "\n Session Number: "+getSessionNumber()+"\n Genre: "+getGenre()+ "\n Creator: " +getCreator(); } }

Clase Film

public class Film { private String title; private String genre; private String creator; private int duration; private short year; private boolean viewed; 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 boolean isViewed() { return viewed; } public void setViewed(boolean viewed) { this.viewed = viewed; } }

Clase Magazine

import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; public class Magazine extends Publication { private int id; public Magazine(String title, Date editionDate, String editoral, String[] authors) { super(title, editionDate, editoral, authors); // TODO Auto-generated constructor stub } public int getId() { return id; } @Override public String toString() { // TODO Auto-generated method stub return "\n Title: "+getTitle()+"\n Editoral:"+getEditoral()+"\n Authors: "+ Arrays.toString(getAuthors())+ "\n Edition Date: "+ new SimpleDateFormat("dd/MM/yyyy").format(getEditionDate()); } }

Clase Movie

public class Movie extends Film{ private int id; private int timeViewed; 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 int getTimeViewed() { return timeViewed; } public void setTimeViewed(int timeViewed) { this.timeViewed = timeViewed; } @Override public String toString() { // TODO Auto-generated method stub return "\n Title: "+getTitle()+ "\n Genre: " +getGenre()+ "\n Year: "+getYear()+ "\n Creator: "+getCreator()+ "\n Duration: "+getDuration()+" hrs."; } }

Clase Serie

public class Serie extends Film{ private int id; private int sessionQuantity; private Chapter[] 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 Chapter[] getChapters() { return chapters; } public void setChapters(Chapter[] chapters) { this.chapters = chapters; } @Override public String toString() { // TODO Auto-generated method stub return "\n Title: "+getTitle()+"\n Creator: "+getCreator()+"\n Genre: "+getGenre()+ "\n Duration: "+getDuration()+"\n Session Quantity: "+getSessionQuantity(); } }
1 respuestas
para escribir tu comentario
    Silvia Rodriguez

    Silvia Rodriguez

    studenthace 6 años

    Aclarando solo imprime la fecha actual en la variable editionDate y mi pregunta es como asignar una fecha cualquiera a una variable tipo Date e imprimirlo?

Curso Básico de Java SE 2018

Curso Básico de Java SE 2018

Java es un lenguaje de programación con el que puedes desarrollar software multiplataforma gracias a la JVM (Máquina Virtual de Java). Aprende las características fundamentales del lenguaje y desarrolla tus propios proyectos. Serás capaz de aplicar desde conceptos básicos, pasando por sus características orientadas a objetos y otros conceptos avanzados como herencia y polimorfismo.

Curso Básico de Java SE 2018
Curso Básico de Java SE 2018

Curso Básico de Java SE 2018

Java es un lenguaje de programación con el que puedes desarrollar software multiplataforma gracias a la JVM (Máquina Virtual de Java). Aprende las características fundamentales del lenguaje y desarrolla tus propios proyectos. Serás capaz de aplicar desde conceptos básicos, pasando por sus características orientadas a objetos y otros conceptos avanzados como herencia y polimorfismo.