Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*Language is java* there is 2 parts to this question. the first picture is the first part, then the other 2 pictures are the second

*Language is java*
there is 2 parts to this question.
the first picture is the first part, then the other 2 pictures are the second part. The second part uses the code from the first part. Thank you!
image text in transcribed
image text in transcribed
image text in transcribed
Directions: You will be creating a Movie class to build and track your movies! 1. Create a new class called Movie. 2. Give the class three private instance variables: a. String variable called title to store the Movie's title b. String variable called rating to store the Movie's rating a Integer variable called minutes to store how many minutes long the movie is 3. Give the class two private static variables: a. Array that holds 3 Movie objects called collection b. Integer variable called movieCollectionCount that is initialized to equal zero 4. Write the default constructor so that it creates the movie Wreck-It Ralph, rated PG, and 108 minutes long 5. Write a second default constructor with the following parameters a. String parameter named title that will set the title of the Movie b. String parameter named rating that will set the rating of the Movie C. Integer parameter named minutes that will set the number of minutes for the Movie 6. Write three accessor methods named getTitle, getRating, and getMinutes (that do what they should do) 7. Create a second class named Movie Tester in the same package as the Movie class (has a main method) 8. Add the following code to the Movie Tester class Movie mi= new Movie(); Movie m2 = new Movie("Toy Story" "G. 81); System.out.println(mi getTitle()+"\t+m1.getRating()+"\+m1.getMinutes()+minutes"); System.out.println(m2.getTitle()+'\t"+m2.getRating()+"\t"+m2.getMinutes0+ minutes) 9. Run the MovieTester class and verify that you get the following output. If you do, you are ready to move on. If you do not, you MUST rework your code until it does: Wreck-It Ralph PG 108 minutes Toy Story G 81 minutes 10. If you get the above output, continue to step #11. If you do not get the above output, DO NOT CONTINUE - return back and fix the issues that your code has before moving on. 11. Delete the 4 lines of code in the Movie Tester class and write your own code that creates your five favorite movies, name them mi, m2, m3, m4, and m5 (be sure to look up their ratings and how many minutes they are to make your code accurate). 12. Write five print statements that print your movie information to the screen (similar to the test code in step #8) Directions: You will be editing your Movie and MovieTester classes from the previous Movie - Part 1 activity 1. Your first task will be to write a new method called print Movie in the Movie class. a. Goal: this method will print movie information (exactly like the Movie Tester did in Part 1) b. The method is a static method of which any movie can use C. The method needs a Movie object as a parameter (pass it a Movie so it can print info) d. The method will not return anything, it will simply print the information 2. When done writing the printMovie method, return to the MovieTester class and do the following: a. Delete all 5 print statements that you previously wrote. b. Add the following line of code: Movie.printMovie(m5); C. Run your code. If done correctly, you should see your 5 movie printed to the screen d. If successful, move on to step #3. If not, return back to step #1 to correct your errors. a. 3. Your next task is to use the static variable and static Array that was created in the Movie Part 1 activity. This will be done by writing a method called addMovieToCollection that will place a chosen movie into your special collection of 3 movies (Array length 3). Do this by following these steps: Write a static method header that returns nothing and takes in a Movie object b. Reminder: the movie collection can only hold 3 movies. So you will need to add an if-else statement in the method. If there are 3 things in the collection, print the following to the screen: "Collection is full ... movie not added!". Otherwise, if the collection is not full, you need to add the movie into the collection. Keep the following in mind: 1. The Movie passed as a parameter should be placed into the collection Array at the location that is determined by the movie Collection Count variable (tracking # of Movies) ii. After the Movie is successfully added to the collection Array, you will need to increase the number of movies in the movieCollection Count. ii. After the Movie is successfully added to the collection, print the name of the movie that was added and a message that says "Successfully added to collection!" C When done with the above process, return to MovieTester do the following: i. Delete the line of code: Movie.printMovie(m5); ii. Add the following four lines of code: Movie.add Movie To Collection(mi); Movie.addMovie To Collection(m2): Movie.addMovie To Collection(m3); Movie.addMovieToCollection(m4); iii. Run your Movie Tester code, you should get output that tells you that your first three movies were added to the collection and a fourth output that says the collection is full: Example: Wreck-It Ralph successfully added to collection! Toy Story successfully added to collection! Mighty Ducks successfully added to collection! Collection is full... movie not added! iv. If you match the above output (with different movie names of course), move on the step #4. If you do not match the output, return to step #3 to correct issues/errors that you have in your code 4. Your final task will be to return to the Movie class and write a static method named printCollection: a. The method will have no parameters and will not return anything b. The method will contain a for loop that will traverse through the collection Array c. The method will print the three Movies in the array: including the position and title Example Output: Movie #1 = Wreck-It Ralph Movie #2 = Toy Story Movie #3 = Mighty Ducks d. Once you have coded the printCollection method, return to the Movie Tester class and... i. Add the following line of code: Movie.printCollection(); il. You should see your first three movies printed and formatted like the above example iii. If you do, congratulations ... you have completed the activity! Make sure that you understand the process that you just completed. iv. If you do not, be sure to return back to step #4 to fix errors/issues that you have

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_2

Step: 3

blur-text-image_3

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions

Question

Use internal communication to shine

Answered: 1 week ago