Czy jest możliwość wykombinowania jakiegoś parametru dla metody interfejsu serialization(), który umożliwiałby podanie jako parametr dowolny typ obiektu w zalezności dla której klasy go używamy?
/** The interface for objects production that is Movie / Series */
public interface Production {
public void addToTheDatabase();
public void serialization();
}
I dwie klasy
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Scanner; // A class for reading data from the input
/** Object class film */
public class Movie implements Production{
/** Title of the movie */
private String title;
/** Movie description */
private String description;
/** The film's director */
private String director;
/** Movie Release Date */
private String releaseDate;
/** Rating movie */
private int rate;
/** The film's budget */
private int budget;
/** Genres movies */
private String[] genres = {"Comedy", "Adventure", "Fantasy", "Animation", "Horror", "Thriller", "Action"};
/** Country film production */
private String[] country = {"USA", "UK", "Poland"};
@Override
public void addToTheDatabase() {
Movie movie = new Movie();
Scanner input = new Scanner(System.in);
System.out.println("Title: ");
movie.title = input.nextLine();
System.out.println("Description: ");
movie.description = input.nextLine();
System.out.println("Director: ");
movie.director = input.nextLine();
System.out.println("Release date: ");
movie.releaseDate = input.nextLine();
System.out.println("Budget: ");
movie.budget = input.nextInt();
serialization(movie);
}
@Override
public void serialization() {
}
/** Object class series */
public class Series implements Production{
/** The title of the show */
private String title;
/** Description of the show */
private String description;
/** Director of the show */
private String director;
/** Release date of the show. */
private String releaseDate;
/** Rating series */
private int rate;
/** Genres serials */
private String[] genres = {"Comedy", "Adventure", "Fantasy", "Animation", "Horror", "Thriller", "Action"};
/** Country of production series */
private String[] country = {"USA", "UK", "Poland"};
@Override
public void addToTheDatabase() {
// TODO Auto-generated method stub
}
@Override
public void serialization() {
// TODO Auto-generated method stub
}
}