You are on page 1of 1

import java.util.

Random;

public class Movie {

String ID;
String title;
String genre;
Integer rating;
Random rand = new Random();
Integer price;
Math.math(5,10);
public Movie(String title, String genre, Integer rating) {
ID = generateID();
this.title = title;
this.genre = genre;
this.rating = rating;
this.price = calculatePrice();
}

public Integer calculatePrice() {


if(genre.equals("Comedy")) {
return (title.length()*500) + 3000;
} else if(genre.equals("Action")) {
return (title.length()*500) + 4000;
} else {
return (title.length()*500) + 5000;
}

public String generateID() {


String tempID = "";
do {
tempID = "";
for(int i = 0 ; i < 2; i++){
tempID += (char)(rand.nextInt(26) + 'A');
}
for(int i = 0 ; i < 3; i++){
tempID += rand.nextInt(10);
}
}while(Main.movieList.contains(tempID));
return tempID;
}

You might also like