PLEASE COMPLETE THE CODES.
package javaprogram;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
/**
* Movie class definition.
*
* @author David Brown
* @version 2019-01-22
*/
public class Movie implements Comparable {
// Constants
public static final int FIRST_YEAR = 1888;
public static final String[] GENRES = { "science fiction", "fantasy",
"drama", "romance", "comedy", "zombie", "action", "historical",
"horror", "war" };
public static final int MAX_RATING = 10;
public static final int MIN_RATING = 0;
/**
* Converts a string of the form "2,3,6" to an array of Integer objects, [2,
* 3, 6]. Used when reading Movie objects from a file.
*
* @param string
* The string to convert to an array.
* @return The array version of string.
*/
public static Integer[] genresStringToList(final String string) {
final ArrayList genresList = new ArrayList<>();
// your code here
// Convert arraylist to an array of Integer.
return genresList.toArray(new Integer[1]);
}
/**
* Testing.
*
* @param args
* Unused.
*/
public static void main(final String[] args) {
// Movie testing
}
/**
* Returns a string of all genres in the Movie.GENRES list. Use for input
* menus. Formatted as " 3: romance"
*
* @return the genres.
*/
public static String menu() {
// your code here
}
// Attributes
private String director = "";
private Integer[] genres = null;
private double rating = 0;
private String title = "";
private int year = 0;
/**
* Instantiates a Movie object.
*
* @param title
* movie title
* @param year
* year of release
* @param director
* name of director
* @param rating
* rating of 1 - 10 from IMDB
* @param genres
* numbers representing movie genres list
*/
public Movie(final String title, final int year, final String director,
final double rating, final Integer[] genres) {
// your code here
}
/*
* (non-Javadoc) Compares this Movie against that Movie. Returns -1 if this Movie
* comes before that Movie, 1 if this Movie comes after that Movie, and 0 if
* the two Movies are the same.
*
* Movies are compared first by title, then by year.
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(final Movie that) {
// your code here
}
/**
* Converts a list of genre integers to a string of genre names.
*
* @return comma delimited string of genre names based upon the current
* movie object's integer genres list. e.g.: [0, 2] returns "science
* fiction, drama"
*/
public String genresListToNames() {
// your code here
}
/**
* Director getter.
*
* @return the director
*/
public String getDirector() {
return this.director;
}
/**
* Genres getter.
*
* @return the genres list
*/
public Integer[] getGenres() {
return this.genres;
}
/**
* Rating getter.
*
* @return the rating
*/
public double getRating() {
return this.rating;
}
/**
* Title getter.
*
* @return the title
*/
public String getTitle() {
return this.title;
}
/**
* Year getter.
*
* @return the year
*/
public int getYear() {
return this.year;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int hash = 0;
for (int i = 0; i < this.title.length(); i++) {
hash += this.title.charAt(i);
}
hash *= this.year;
return hash;
}
/**
* Creates a formatted string of Movie key data in the format "title, year".
* Ex: "Zulu, 1964".
*
* @return a Movie key as a string
*/
public String key() {
return String.format("%s, %d", this.title, this.year);
}
/**
* Director setter.
*
* @param director
* the new director value
*/
public void setDirector(final String director) {
this.director = director;
}
/**
* Genres setter.
*
* @param genres
* the new list of numeric genres
*/
public void setGenres(final Integer[] genres) {
this.genres = genres;
}
/**
* Rating setter.
*
* @param rating
* the new rating
*/
public void setRating(final double rating) {
this.rating = rating;
}
/**
* Title setter.
*
* @param title
* the new title
*/
public void setTitle(final String title) {
this.title = title;
}
/**
* Year setter.
*
* @param year
* the new year
*/
public void setYear(final int year) {
this.year = year;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString() Creates a formatted string of movie
* data.
*/
@Override
public String toString() {
// your code here
}
/**
* Writes a single line of movie data to an open file in the format
* title|year|director|rating|codes
*
* @param ps
* output printstream
*/
public void write(final PrintStream ps) {
// your code here
}
/**
* Converts a genres list of the form [2,3,7] to a string "2,3,7" for
* writing Movie data to a file.
*
* @return the genres list string
*/
private String genresListToString() {
// your code here
}
}/***********************************Movie.java****************/
package javaprogram;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
/**
* Movie class definition.
*
* @author David Brown
* @version 2019-01-22
*/
public class Movie implements Comparable<Movie> {
// Constants
public static final int FIRST_YEAR = 1888;
public static final String[] GENRES = { "science
fiction", "fantasy", "drama", "romance", "comedy", "zombie",
"action",
"historical", "horror", "war" };
public static final int MAX_RATING = 10;
public static final int MIN_RATING = 0;
/**
* Converts a string of the form "2,3,6" to an array of
Integer objects, [2, 3,
* 6]. Used when reading Movie objects from a
file.
*
* @param string The string to convert to an
array.
* @return The array version of string.
*/
public static Integer[] genresStringToList(final
String string) {
final ArrayList<Integer>
genresList = new ArrayList<>();
String[] list =
string.split(",");
for (String string2 : list) {
genresList.add(Integer.parseInt(string2));
}
// Convert arraylist to an array
of Integer.
return genresList.toArray(new
Integer[10]);
}
/**
* Testing.
*
* @param args Unused.
*/
public static void main(final String[] args) {
// Movie testing
}
/**
* Returns a string of all genres in the Movie.GENRES
list. Use for input menus.
* Formatted as " 3: romance"
*
* @return the genres.
*/
public static String menu() {
String menu = "";
int i = 1;
for (String string : GENRES) {
menu = i + ":
" + string + "\n";
}
return menu;
}
// Attributes
private String director = "";
private Integer[] genres = null;
private double rating = 0;
private String title = "";
private int year = 0;
/**
* Instantiates a Movie object.
*
* @param title movie title
* @param year year of release
* @param director name of director
* @param rating rating of 1 - 10 from IMDB
* @param genres numbers representing movie genres
list
*/
public Movie(final String title, final int year, final
String director, final double rating,
final Integer[]
genres) {
this.title = title;
this.year = year;
this.director = director;
this.genres = genres;
this.rating = rating;
}
/*
* (non-Javadoc) Compares this Movie against that
Movie. Returns -1 if this
* Movie comes before that Movie, 1 if this Movie comes
after that Movie, and 0
* if the two Movies are the same.
*
* Movies are compared first by title, then by
year.
*
* @see
java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(final Movie that) {
if (this.year < that.year) {
return
-1;
} else if (this.year >
that.year) {
return
1;
} else {
return
0;
}
}
/**
* Converts a list of genre integers to a string of
genre names.
*
* @return comma delimited string of genre names based
upon the current movie
* object's integer genres list. e.g.: [0, 2] returns
"science fiction,
* drama"
*/
public String genresListToNames() {
String genre = "";
for (String string : GENRES) {
genre +=
string + ",";
}
return genre;
}
/**
* Director getter.
*
* @return the director
*/
public String getDirector() {
return this.director;
}
/**
* Genres getter.
*
* @return the genres list
*/
public Integer[] getGenres() {
return this.genres;
}
/**
* Rating getter.
*
* @return the rating
*/
public double getRating() {
return this.rating;
}
/**
* Title getter.
*
* @return the title
*/
public String getTitle() {
return this.title;
}
/**
* Year getter.
*
* @return the year
*/
public int getYear() {
return this.year;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
int hash = 0;
for (int i = 0; i <
this.title.length(); i++) {
hash +=
this.title.charAt(i);
}
hash *= this.year;
return hash;
}
/**
* Creates a formatted string of Movie key data in the
format "title, year". Ex:
* "Zulu, 1964".
*
* @return a Movie key as a string
*/
public String key() {
return String.format("%s, %d",
this.title, this.year);
}
/**
* Director setter.
*
* @param director the new director value
*/
public void setDirector(final String director) {
this.director = director;
}
/**
* Genres setter.
*
* @param genres the new list of numeric genres
*/
public void setGenres(final Integer[] genres) {
this.genres = genres;
}
/**
* Rating setter.
*
* @param rating the new rating
*/
public void setRating(final double rating) {
this.rating = rating;
}
/**
* Title setter.
*
* @param title the new title
*/
public void setTitle(final String title) {
this.title = title;
}
/**
* Year setter.
*
* @param year the new year
*/
public void setYear(final int year) {
this.year = year;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString() Creates a formatted
string of movie data.
*/
@Override
public String toString() {
return "Movie [director=" +
director + ", genres=" + Arrays.toString(genres) + ", rating=" +
rating + ", title="
+ title + ", year=" + year + "]";
}
/**
* Writes a single line of movie data to an open file
in the format
* title|year|director|rating|codes
*
* @param ps output printstream
* @throws FileNotFoundException
*/
public void write(PrintStream ps) throws
FileNotFoundException {
ps = new PrintStream(new
File("movies.txt"));
ps.append(title + "|" + year + "|"
+ director + "|" + rating);
ps.append("\n");
}
/**
* Converts a genres list of the form [2,3,7] to a
string "2,3,7" for writing
* Movie data to a file.
*
* @return the genres list string
*/
private String genresListToString() {
String genreList = "";
for (int i : genres) {
genreList +=
i + ",";
}
return genreList;
}
}
Please let me know if you have any doubt or modify the answer, Thanks:)
PLEASE COMPLETE THE CODES. package javaprogram; import java.io.PrintStream; import java.util.ArrayList; import java.util.Scanner; /** * Movie class...
How to complete this methods: import java.io.FileInputStream; import java.io.FileNotFoundException; import java.time.LocalDate; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; /** * Utility class that deals with all the other classes. * * @author EECS2030 Summer 2019 * */ public final class Registrar { public static final String COURSES_FILE = "Courses.csv"; public static final String STUDENTS_FILE = "Students.csv"; public static final String PATH = System.getProperty("java.class.path"); /** * Hash table to store the list of students using their...
package cards; import java.util.ArrayList; import java.util.Scanner; public class GamePlay { static int counter = 0; private static int cardNumber[] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; private static char suitName[] = { 'c', 'd', 'h', 's' }; public static void main(String[] args) throws CardException, DeckException, HandException { Scanner kb = new Scanner(System.in); System.out.println("How many Players? "); int numHands = kb.nextInt(); int cards = 0; if (numHands > 0) { cards = 52 / numHands; System.out.println("Each player gets " + cards + " cards\n"); } else...
Complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class WordDetective { /** * This returns a string containing the char ch, count times. * For example calling with 'a', 5 would return: * "aaaaa" * * @param ch The character to repeat. * @param count The number of the character. * @return A string with count number of ch. */ public static String charToString(char ch, int count) { return null; //TODO }
CS HELP Use sets to solve this problem package log; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class LogParser { /** * Returns a list of SuspectEntries corresponding to the CSV data supplied by the given Reader. * * The data contains one or more lines of the format: * * Marc,413-545-3061,1234567890 * * representing a name, phone number, and passport number. * * @param r an open Reader object * @return a list of SuspectEntries...
Given java code is below, please use it!
import java.util.Scanner;
public class LA2a {
/**
* Number of digits in a valid value sequence
*/
public static final int SEQ_DIGITS = 10;
/**
* Error for an invalid sequence
* (not correct number of characters
* or not made only of digits)
*/
public static final String ERR_SEQ = "Invalid
sequence";
/**
* Error for...
complete this in java import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class WordDetective { /** * Picks the first unguessed word to show. * Updates the guessed array indicating the selected word is shown. * * @param wordSet The set of words. * @param guessed Whether a word has been guessed. * @return The word to show or null if all have been guessed. */ public static String pickWordToShow(ArrayList<String> wordSet, boolean []guessed) { return null;...
Below are the Car class and Dealership class that I
created In the previous lab
import java.util.ArrayList;
class Car
{
private String make;
private String model;
private int year;
private double transmission;
private int seats;
private int maxSpeed;
private int wheels;
private String type;
public Car()
{
}
public Car(String make, String model, int year, double transmission, int seats, int maxSpeed, int wheels, String type) {
this.make = make;
this.model = model;
this.year = year;
this.transmission = transmission;
this.seats =...
public enum Rating { GENERAL(0), PARENTALGUIDANCE(1), MATURE(2); private int minAge; private Rating(int i) { minAge = i; } public int getMinAge() { return minAge; } public void setMinAge(int age) { minAge = age; } public String toString() { switch(this) { case GENERAL: return "G"; case PARENTALGUIDANCE: return "P"; case MATURE: return...
Inheritance and Polymorphism (use Pet.java) You are given a class named Pet.java. Create two child classes named Cat.java and Dog.java. Cat.java should add attributes for color and breed. Dog.java should add attributes for breed and size (use String for small, medium, large). Add appropriate constructors, getter/setter methods and toString() methods. In a separate file named PetDriver.java, create a main. In the main, create an ArrayList of Pet. Add an instance of Cat and an instance of Dog to the ArrayList....
Write code for RSA encryption package rsa; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; public class RSA { private BigInteger phi; private BigInteger e; private BigInteger d; private BigInteger num; public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the message you would like to encode, using any ASCII characters: "); String input = keyboard.nextLine(); int[] ASCIIvalues = new int[input.length()]; for (int i = 0; i < input.length(); i++) { ASCIIvalues[i] = input.charAt(i); } String ASCIInumbers...