package data;

import java.util.ArrayList;
import java.util.HashMap;

public class DataBase {

	private static DataBase instance = new DataBase();
		
	private ArrayList<Movie> movies = new ArrayList();
	private ArrayList<Actor> actors = new ArrayList();
	private ArrayList<Director> directors = new ArrayList();
	private ArrayList<User> users = new ArrayList();
	private HashMap<Integer,Integer> actings = new HashMap<>();
	private HashMap<Integer,Integer> directings = new HashMap<>();
	
	private DataBase() {}
	
	
		public void addActing(int actorId,int movieId) {
			actings.put(actorId, movieId);
		}
		
		public void addDirecting(int dierctorID, int movieId) {
			directings.put(dierctorID, movieId);
		}
	
		public void addMovie(Movie m) {
			if(movies.contains(m.getId()))
			return;
			movies.add(m);
		}
		
		public void addUser(String userName, float rating, int movieId) {
			for(User u : users) {
				if(u.getName().equals(userName)) {
					u.addRating(movieId, rating);
					return;
				}
			}
			User u = new User(userName);
			u.addRating(movieId, rating);
			users.add(u);
		}
		
		public void addActor(Actor a) {
			actors.add(a);
		}
		
		public void addDirector(Director d) {
			directors.add(d);
		}
		
		public void addUserRating(User u) {
			
		}
		
		public void printMovies() {
			for( Movie m : movies) {
				System.out.println(m.toString());
			}
		}
		
		public static DataBase getInstance() {
			return  instance;
		}
}
