Question

In: Computer Science

Language: Java To be able to code a class structure with appropriate attributes and methods. To...

Language: Java

To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method.

Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure to include the appropriate setter, getter methods and toString to display descriptions in a nicely formatted output. In addition to default constructors, define overloaded constructors to accept and initialize class data. When using a default constructor, use the setter from the main program to set values. Use a static variable to keep track of the number of objects in the video library. Display the number of items prior to listing them.

Data for movies should contain attributes for the title, release date, genre, studio, and streaming source (Netflix, Prime or Hulu).

Data for TvShow should contain the title, genre (same as others), date of the first episode, number of seasons, network, and running time.

Data for MiniSeries should include attributes for title, genre (same as others), number of episodes, running time, lead actor or actress.

Create a main driver class to create several objects of each type of video content. Use examples of both the default and overloaded constructors. Then display your complete video library with all fields.

All required variables are members of the class. Appropriate use of access specifiers. Encapsulation is implemented with setters and getters. Code is well structured and commented. Code meets standard Java conventions.

There is a default (no-arg) constructor, and an overloaded constructor for each video type. Objects created all have appropriate data content. A static variable is implemented and correctly counts objects created.

Methods are established in the class for all appropriate setters and getters. Inheritance is properly demonstrated with appropriate attributes, methods, and object instantiation.

The VideoLibrary class properly creates all the required objects and displays the entire video library with the number of items and all the data content in a nicely formatted output.

Solutions

Expert Solution

SOLUTION:

Short Summary:

Provided the source code and sample output as per the requirements.
*************Please upvote the answer and appreciate our time.***********

SOURCE CODE:

VideoContent.java:

/**

*

* VideoContent parent class

*/

public class VideoContent {

// attributes of parent class

String title;

String genre;

static int counter = 0;

public VideoContent() {

title = "";

genre = "";

counter++;

}

public VideoContent(String title, String genre) {

this.title = title;

this.genre = genre;

VideoContent.counter++;

}

// getter of title

public String getTitle() {

return title;

}

// setter of title

public void setTitle(String title) {

this.title = title;

}

// getter of genre

public String getGenre() {

return genre;

}

// setter of genre

public void setGenre(String genre) {

this.genre = genre;

}

// getter of counter

public static int getCounter() {

return counter;

}

@Override

public String toString() {

return "Title : " + title + "\nGenre : " + genre;

}

}

TvShow.java:

/**

*

* TvShows class

*/

public class TvShow extends VideoContent {

String firstEpisodeDate;

int seasonsNum;

String network;

String runningTime;

public TvShow() {

super();

firstEpisodeDate = "";

seasonsNum = 0;

network = "";

runningTime = "";

}

public TvShow(String title, String genre, String firstEpisodeDate, int seasonsNum, String network, String runningTime) {

super(title, genre);

this.firstEpisodeDate = firstEpisodeDate;

this.seasonsNum = seasonsNum;

this.network = network;

this.runningTime = runningTime;

}

// getters and setters of TvShow

public String getFirstEpisodeDate() {

return firstEpisodeDate;

}

public void setFirstEpisodeDate(String firstEpisodeDate) {

this.firstEpisodeDate = firstEpisodeDate;

}

public int getSeasonsNum() {

return seasonsNum;

}

public void setSeasonsNum(int seasonsNum) {

this.seasonsNum = seasonsNum;

}

public String getNetwork() {

return network;

}

public void setNetwork(String network) {

this.network = network;

}

public String getRunningTime() {

return runningTime;

}

public void setRunningTime(String runningTime) {

this.runningTime = runningTime;

}

@Override

public String toString() {

String resultString = super.toString();

resultString += "\nFirst Episode Date : " + firstEpisodeDate + "\nNumber of Seasons :"

+ seasonsNum + "\nNetwork : " + network + "\nRunning Time : " + runningTime;

return resultString;

}

}

Movies.java:

/**

*

* Movies class

*/

public class Movies extends VideoContent {

String releaseDate;

String studio;

String streamingSource;

public Movies() {

super();

releaseDate = "";

studio = "";

streamingSource = "";

}

public Movies(String title, String genre, String releaseDate, String studio, String streamingSource) {

super(title, genre);

this.releaseDate = releaseDate;

this.studio = studio;

this.streamingSource = streamingSource;

}

// getters of releaseDate

public String getReleaseDate() {

return releaseDate;

}

// setters of releaseDate

public void setReleaseDate(String releaseDate) {

this.releaseDate = releaseDate;

}

// getters of studio

public String getStudio() {

return studio;

}

// setters of studio

public void setStudio(String studio) {

this.studio = studio;

}

// getters of streamingsource

public String getStreamingSource() {

return streamingSource;

}

// setters of streamingsource

public void setStreamingSource(String streamingSource) {

this.streamingSource = streamingSource;

}

@Override

public String toString() {

String resultString = super.toString();

resultString += "\nRelease Date : " + releaseDate + "\nStudio : " + studio + "\nStreaming Source : " + streamingSource;

return resultString;

}

}

MiniSeries.java:

/**

*

* MiniSeries class

*/

public class MiniSeries extends VideoContent {

// attributes of MiniSeries class

int episodesNum;

String runningTime;

String leadActor;

public MiniSeries() {

super();

episodesNum = 0;

runningTime = "";

leadActor = "";

}

public MiniSeries(String title, String genre, int episodesNum, String runningTime, String leadActor) {

super(title, genre);

this.episodesNum = episodesNum;

this.runningTime = runningTime;

this.leadActor = leadActor;

}

// getters and setters of MiniSeries

public int getEpisodesNum() {

return episodesNum;

}

public void setEpisodesNum(int episodesNum) {

this.episodesNum = episodesNum;

}

public String getRunningTime() {

return runningTime;

}

public void setRunningTime(String runningTime) {

this.runningTime = runningTime;

}

public String getLeadActor() {

return leadActor;

}

public void setLeadActor(String leadActor) {

this.leadActor = leadActor;

}

@Override

public String toString() {

String resultString = super.toString();

resultString += "\nNumber of episodes : " + episodesNum + "\nRunning Time : " + runningTime + "\nLead Actor :" + leadActor;

return resultString;

}

}

VideoContentDriver.java:

/**

*

* Main Driver class

*/

public class VideoContentDriver {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// create object for TvShow using default constructor

TvShow tvShow = new TvShow();

// using setters

tvShow.setTitle("Dark");

tvShow.setGenre("Science Fiction thiller");

tvShow.setFirstEpisodeDate("December 1, 2017");

tvShow.setSeasonsNum(5);

tvShow.setNetwork("flix");

tvShow.setRunningTime("44minutes");

// create object for TvShow using paramterized constructor

TvShow tvShow1 = new TvShow("Sherlock Holmes", "Fictional ", "April 24, 1984", 7, "flix", "55 min");

// create object for Movies using default constructor

Movies movies = new Movies();

movies.setTitle("Pink");

movies.setGenre("Crime");

movies.setReleaseDate("September 16, 2016");

movies.setStudio("Zee studio");

movies.setStreamingSource("NetFlix");

// create object for TvShow using paramterized constructor

Movies movies1 = new Movies("Black Panther", "Action Adventure", "February 16, 2018", "Marvel Studios", "Prime");

MiniSeries miniSeries = new MiniSeries();

miniSeries.setTitle("Chernobyl");

miniSeries.setGenre("Historical drama ");

miniSeries.setEpisodesNum(5);

miniSeries.setRunningTime("70 minutes ");

miniSeries.setLeadActor("Jared Harris ");

MiniSeries miniSeries1 = new MiniSeries("When They See Us", "Crime", 4, "50 mins", "Asante Blackk");

System.out.println("Number of items: " + VideoContent.getCounter());

// display result

String tvshowResult = tvShow.toString();

System.out.println("\n***** TvShow Result ****\n" + tvshowResult);

// display result

String tvshowResult1 = tvShow1.toString();

System.out.println("\n***** TvShow Result ****\n" + tvshowResult1);

// display result

String moviesResult = movies.toString();

System.out.println("\n***** Movies Result ****\n" + moviesResult);

// display result

String moviesResult1 = movies1.toString();

System.out.println("\n***** Movies Result ****\n" + moviesResult1);

// display result

String miniResult = miniSeries.toString();

System.out.println("\n***** Movies Result ****\n" + miniResult);

// display result

String miniResult1 = miniSeries1.toString();

System.out.println("\n***** Movies Result ****\n" + miniResult1);

}

}

SAMPLE OUTPUT:


Related Solutions

Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To...
Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method. Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure to...
How to write a Java program that has a base class with methods and attributes, subclasses...
How to write a Java program that has a base class with methods and attributes, subclasses with methods and attributes. Please use any example you'd like.
Language: Java I have written this code but not all methods are running. First method is...
Language: Java I have written this code but not all methods are running. First method is running fine but when I enter the file path, it is not reading it. Directions The input file must be read into an input array and data validated from the array. Input file format (500 records maximum per file): comma delimited text, should contain 6 fields: any row containing exactly 6 fields is considered to be invalid Purpose of this code is to :...
Write a class called VLPUtility with the following static methods: Java Language 1. concatStrings that will...
Write a class called VLPUtility with the following static methods: Java Language 1. concatStrings that will accept a variable length parameter list of Strings and concatenate them into one string with a space in between and return it. 2. Overload this method with two parameters, one is a boolean named upper and one is a variable length parameter list of Strings. If upper is true, return a combined string with spaces in upper case; otherwise, return the combined string as...
java code Add the following methods to the LinkedQueue class, and create a test driver for...
java code Add the following methods to the LinkedQueue class, and create a test driver for each to show that they work correctly. In order to practice your linked list cod- ing skills, code each of these methods by accessing the internal variables of the LinkedQueue, not by calling the previously de?ined public methods of the class. String toString() creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging...
Array of Hope! Write code for a Java class ArrayPair with the following fields and methods:...
Array of Hope! Write code for a Java class ArrayPair with the following fields and methods: ArrayPair - arr1 [] : int - arr2 [] : int Fields - length1 : int - length2 : int + ArrayPair (int arraySize) Methods + add (int arrNumber, int value) : void + remove (int arrNumber) : void + equal () : boolean + greater () : boolean + print () : void Thus, there are two arrays of integers in the class...
language is java Use method overloading to code an operation class called CircularComputing in which there...
language is java Use method overloading to code an operation class called CircularComputing in which there are 3 overloaded methods as follows: computeObject(double radius)-compute area of a circle computeObject(double radius, double height)-compute area of a cylinder computeObject(double radiusOutside, double radiusInside, double height)-compute volume of a cylindrical object These overloaded methods must have a return of computing result in each Then override toString() method so it will return the object name, the field data, and computing result Code a driver class...
Language java Rewrite the method getMonthusing the "this" parameter CODE: import java.util.Scanner; public class DateSecondTry {...
Language java Rewrite the method getMonthusing the "this" parameter CODE: import java.util.Scanner; public class DateSecondTry { private String month; private int day; private int year; //a four digit number. public void writeOutput() { System.out.println(month + " " + day + ", " + year); } public void readInput() { Scanner keyboard = new Scanner(System.in); System.out.println("Enter month, day, and year."); System.out.println("Do not use a comma."); month = keyboard.next(); day = keyboard.nextInt(); year = keyboard.nextInt(); } public int getDay() { return day;...
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods:...
**********Java language************ 1-      (Conversions between Celsius and Fahrenheit) Write a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */ public static double celsiusToFahrenheit(double celsius) /** Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is: Celsius = (5.0 / 9) * (Fahrenheit – 32) Fahrenheit = (9.0 / 5) * Celsius + 32 Program output should be like: If you want to convert from Fahrenheit To Celsius press 0...
Please Code Using Java Create a class called SoccerPlayer Create 4 private attributes: First Name, Last...
Please Code Using Java Create a class called SoccerPlayer Create 4 private attributes: First Name, Last Name, Games, and Goals Have two constructors Constructor 1 – default constructor; all values to "NONE" or zero Constructor 2 – accepts input of first name, last name, games and goals. Create get and set methods for each of the four attributes Create a method the returns a double that calculates the average goals per game This method checks for zero games played: If...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT