Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THIS IS A SINGLE JAVA PROJECT. PLEASE WRITE A CODE THAT FOLLOWS THE INSTRUCTIONS COMPLETELY!! In this assignment, continuing with the theme of streaming series,

THIS IS A SINGLE JAVA PROJECT. PLEASE WRITE A CODE THAT FOLLOWS THE INSTRUCTIONS COMPLETELY!!

image text in transcribedimage text in transcribedimage text in transcribed

In this assignment, continuing with the theme of streaming series, we'll model this in a more object-oriented style. In particular, this assignment will give you practice with the following ideas: - basic principles of encapsulation and information hiding (e.g., using access modifiers) - constructor creation and overloading - practice with defensive programming and exceptions - exposure to java enumerations NOTE: The Scanner class will no longer be used - so don't use it anywhere, just hardcode your input right in the main method. To get started, open IntelliJ and create a new java project named asg2 (be sure to put it in your ist242/assignments directory). Part 1: Modeling an episode Create a new class named Episode. The class should include fields to store the episode's: title, runtime, and season number (choose appropriate access modifiers and data types for each field). Next, provide a class constructor. The constructor should take as parameters the season number, episode title, and the runtime and initialize the corresponding fields. Include a defensive/validation check in the constructor that throws a IllegalArgumentException if the runtime or season number provided is negative. Add getter methods for each field. Also include a single setter method called setRuntime (..). Lastly, override the toString () method for the class to print the following info: S season-number title runtime where anything in ..isreplacedbyitscorrespondingfielddontactuallyincludetheangled braces in your toString () (these just denote placeholders where a given field should be printed). Part 2: Modeling a streaming platform Next, create a class StreamingPlatform that stores both the name of the platform and the monthly subscription price. Have a constructor that takes this information as parameters and initializes the fields. Now add a getter method for the name as well as a method getPrice (. .) that takes a boolean (if the boolean passed into the method is true, then return the price for a yearly subscription for 12 months minus a half the monthly price; otherwise just return the monthly price). Lastly override the toString () method to return the name of the streaming platform. Part 3: Modeling a Series Finally, create a class Series that stores: (1) a list of Episodes, (2) a streaming platform (use the class you just wrote for this), (3) the name of the series, (4) the start year, and finally (5) the genre of the series. Use the java library Year class as the datatype for the year field. Here's an example illustrating how you can create a Year object (the code below does not go in the Series class-just an example): Year yr = Year.now (); // inits a var yr to the current year yr = Year.of (1998); // updates var yr to the year 1997 We'll only model/permit a fixed number of genres for our Series object. We'll use an enumerated type to limit these to: - horror, drama, sci-fi, romance, true-crime For more information on enumerated types, refer to the java "trails" info page: https://docs . oracle.com/javase/tutorial/java/java00/enum.html You can either define the enum either within the Series class, or you can create a separate file named Genre by right clicking the blue 'src' pkg > new java class > and selecting "Enum." Use the enum you write as the datatype for the genre field. The class should offer two (overloaded) constructors. 1. the first constructor should take: - the name of the series, - the release year (use java's Year class as the type), - the genre (use the Genre enum as the type), - a list of episodes (use your Episode class and ArrayList), - a streaming platforms (use your StreamingPlatform as the type) 2. the second constructor accepts fewer parameters: - the name of the series, - a genre, - a streaming platform Be sure each constructor initializes all fields to either the value passed in or some sensible default value. Once the constructors are written, supply the usual getters for each field in addition to the following two methods: - a private static method called validateSeries (..) that takes a list of episodes and throws a IllegalArgumentException if the season numbers are not in ascending order. This method should be called once inside the constructor. - a public method that returns the number of seasons (use the episode list to compute this). As with the other classes, override toString () and make it return a string of the form: Platform: streaming-platform tostring for each episode here - each on a newline) Part 4: Bringing it all Together Latly, create a new class, Tester, and add a main method to it. Inside the main, instantiate a Series that stores multiple episodes of the same series spanning different seasons. Make sure your validation check works (i.e. try to pass a list of episodes into the constructor where the season numbers per episode are not in ascending order). Print the Series out once instantiated. Here's some sample output for a fake series: Title: Sopranos: The Fake Mini Series (1990, seasons: 4) Genre: DRAMA Platform: HBO Max S1 - The Fam - 48.20 S2 - Denial, Anger, Acceptance - 45.60 S2 - Happy times - 44.70 S3 - Boca - 50.60 S4 - Army of one - 60.24 You can choose whichever series you'd like to model (you don't have to model the series exhaustive detail with all episodes - though it should span a few seasons to exercise your validation/defensive checks). Handin Export your project to a .zip file and submit the zip on canvas. You can do this through IntelliJ by going to File > Export > Export to Zip File. It is your responsibility to verify that what you turned in is what you intended to turn in (download, unzip the file, and check)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions