L
Lucas
Gast
Hey Leute,
ich bin noch ganz neu in Java und möchte mir gerne meine eigene FilmBibliothek schreiben.
Ich habe meine Hauptklasse "MovieDesk" und lese hier mit BufferedReader ein String als Filmnamen ein.
Ich möchte diesen dann gern als Film in meiner Liste movies speichern die vom Typ Movie ist.
Movie ist eine eigene Klasse.
folgend nochmal beide Klassen für besseres Verständniss:
--------------------------------------------------------------------------
Danke schonmal für eure Hilfe.
Lg Lucas
ich bin noch ganz neu in Java und möchte mir gerne meine eigene FilmBibliothek schreiben.
Ich habe meine Hauptklasse "MovieDesk" und lese hier mit BufferedReader ein String als Filmnamen ein.
Ich möchte diesen dann gern als Film in meiner Liste movies speichern die vom Typ Movie ist.
Movie ist eine eigene Klasse.
folgend nochmal beide Klassen für besseres Verständniss:
Java:
package moviedesk;
import java.util.*;
import java.io.*;
import java.awt.AWTException;
/**
*
* @author thesquirrel91
*/
public class MovieDesk {
//public class Movie {}
private List<Movie> movies;
private Movie movie;
public MovieDesk(Movie movie) {
this.movies = new ArrayList<Movie>();
this.movie = movie;
}
/**
* delete the chosen movie from the database
* @param id of the movie what should be deleted
* @return boolean of success or not
*/
public boolean deleteMovie(int id) {
return true;
}
/**
* add a movieitem to the database
* @param title of the movie
* @return boolean of success or not
*/
public boolean addMovie(String title) {
return true;
}
/**
* updates the movie with specific id
* @param movie
* @return boolean of success or not
*/
public boolean updateMovie(Movie movie) {
return true;
}
/**
* find a movie by id
* @param id of the movie
* @return movie
*/
public Movie getMovie(int id) {
return movie;
}
/**
* find a movie by title
* @param title of the movie
* @return movie
*/
public Movie getMovie(String title) {
return movie;
}
/**
* return the list of all movies
* @return the list of all movies
*/
public List<Movie> getMovies() {
return movies;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws AWTException, IOException {
System.out.println("Welcome to MovieDesk 0.1");
System.out.println("");
System.out.println("Enter the name of the Movie:");
BufferedReader bin = new BufferedReader(new InputStreamReader(System.in));
String name = bin.readLine();
System.out.println("Name of the movie: " + name);
}
}
--------------------------------------------------------------------------
Java:
package moviedesk;
import java.util.*;
/**
*
* @author thesquirrel91
*/
public class Movie {
private int id;
private String title;
private String description;
private boolean seen;
private List<Person> person;
private float rating;
private String imdb;
/**
* allocate all variables
* @param id of movie
* @param title
* @param seen
* @param rating
* @param imdb
*/
public Movie(int id, String title, String description, boolean seen, float rating, String imdb) {
this.id = id;
this.title = title;
this.description = description;
this.seen = seen;
this.rating = rating;
this.imdb = imdb;
this.person = new ArrayList<Person>();
}
/**
* return movie id
* @return id
*/
public int getId() {
return id;
}
/**
* return title
* @return title
*/
public String getTitle() {
return title;
}
/**
* return description
* @return description
*/
public String getDescription() {
return description;
}
/**
* return seen boolean
* @return seen
*/
public boolean getSeen() {
return seen;
}
/**
* return rating
* @return rating
*/
public float getRating() {
return rating;
}
/**
* get imdb link
* @return imdb
*/
public String getImdb() {
return imdb;
}
/**
* set movie id
* @return id
*/
public void setId() {
this.id = id;
}
/**
* set movie title
* @return title
*/
public void setTitle() {
this.title = title;
}
}
Danke schonmal für eure Hilfe.
Lg Lucas