SlideShare a Scribd company logo
1 of 9
Question: Write the Java code below in IDE ECLIPSE enviroment and provide screenshots
of the execution.
Project
Media Rental System
Before attempting this project, be sure you have completed all of the reading assignments, non-
graded exercises, examples, discussions, and assignments to date.
Design and implement Java program as follows:
1) Media hierarchy:
Create Media, EBook, MovieDVD, and MusicCD classes from Week 3 -> Practice
Exercise - Inheritance solution.
Add an attribute to Media class to store indication when media object is rented versus
available. Add code to constructor and create get and set methods as appropriate.
Add any additional constructors and methods needed to support the below
functionality
2) Design and implement Manager class which (Hint: check out Week 8 Reading and Writing
files example):
stores a list of Media objects
has functionality to load Media objects from files
creates/updates Media files
has functionality to add new Media object to its Media list
has functionality to find all media objects for a specific title and returns that list
has functionality to rent Media based on id (updates rental status on media, updates
file, returns rental fee)
3) Design and implement MediaRentalSystem which has the following functionality:
user interface which is either menu driven through console commands or GUI buttons
or menus. Look at the bottom of this project file for sample look and feel. (Hint: for
command-driven menu check out Week 2: Practice Exercise - EncapsulationPlus and
for GUI check out Week 8: Files in GUI example)
selection to load Media files from a given directory (user supplies directory)
selection to find a media object for a specific title value (user supplies title and should
display to user the media information once it finds it - should find all media with that
title)
selection to rent a media object based on its id value (user supplies id and should
display rental fee value to the user)
selection to exit program
4) Program should throw and catch Java built-in and user-defined exceptions as appropriate
5) Your classes must be coded with correct encapsulation: private/protected attributes, get
methods, and set methods and value validation
6) There should be appropriate polymorphism: overloading, overriding methods, and dynamic
binding
7) Program should take advantage of the inheritance properties as appropriate
Expert Answer
This solution was written by a subject matter expert. It's designed to help students like you learn
core concepts.
SOLUTION-
Note :- I have solve the problem in Java code if you have any doubt just let me know
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Media {
int id;
String title;
int year, chapter;
boolean available;
Media() {
}
public Media(int id, String title, int year, int chapter, boolean available) {
this.id = id;
this.title = title;
this.year = year;
this.chapter = chapter;
this.available = available;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getYear() {
return year;
}
public void setYear(int year) {
this.year = year;
}
public int getChapter() {
return chapter;
}
public void setChapter(int chapter) {
this.chapter = chapter;
}
public boolean isAvailable() {
return available;
}
public void setAvailable(boolean available) {
this.available = available;
}
}
class EBook extends Media {
EBook(int id, String title, int year, int chapter, boolean available) {
super(id, title, year, chapter, available);
}
@Override
public String toString() {
return "EBook [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" +
this.year
+ " available:" + this.available + "]n";
}
}
class MovieDVD extends Media {
MovieDVD(int id, String title, int year, int chapter, boolean available) {
super(id, title, year, chapter, available);
}
@Override
public String toString() {
return "MovieDVD [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" +
this.year
+ " available:" + this.available + "]n";
}
}
class MusicCD extends Media {
MusicCD(int id, String title, int year, int chapter, boolean available) {
super(id, title, year, chapter, available);
}
@Override
public String toString() {
return "MusicCD [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" +
this.year
+ " available:" + this.available + "]n";
}
}
class Manager {
static List<Media> list=new ArrayList<>();;
Manager() {
}
public boolean LoadMedia(String path) {
try {
File myObj = new File(path);
Scanner myReader = new Scanner(myObj);
while (myReader.hasNextLine()) {
String data = myReader.nextLine();
String[] str = data.split(" ");
if (str[0].equals("EBook")) {
list.add(new EBook(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]),
Integer.parseInt(str[4]), Boolean.parseBoolean(str[5])));
}else if(str[0].equals("MusicCD")) {
list.add(new MusicCD(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]),
Integer.parseInt(str[4]), Boolean.parseBoolean(str[5])));
}else {
list.add(new MovieDVD(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]),
Integer.parseInt(str[4]), Boolean.parseBoolean(str[5])));
}
}
System.out.println(list);
myReader.close();
return true ;
} catch (FileNotFoundException e) {
System.out.println("An error occurred.");
e.printStackTrace();
return false;
}
}
public void findMedia(String title) {
for(Media m : list) {
if(m.getTitle().equals(title))
System.out.print(m.toString());
}
}
public void rentMedia(int id) {
for(Media m : list ) {
if(m.getId()==id) {
if(m.isAvailable())
System.out.println("media successfully rented out ");
else
System.out.println("Media with id="+id+" is not available for rent ");
}
}
}
}
public class MediaRentalSystem {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (Menu()) {
int choice = 0;
System.out.println("Enter choice");
choice = sc.nextInt();
Manager m = new Manager();
switch (choice) {
case 1:
//String path = "C:UsersAdminDocumentsworkspace-spring-tool-suite-4-
4.9.0.RELEASECore-Javasrcmedia.txt";
System.out.println("Enter file path load media ");
String path=sc.next();
m.LoadMedia(path);
break;
case 2:
System.out.println("Enter media title ");
String title=sc.next();
m.findMedia(title);
break;
case 3:
System.out.println("Enter media id :");
int id =sc.nextInt();
m.rentMedia(id);
break;
case 9:
System.exit(0);
break;
default:
System.out.println("Enter valid choice ");
break;
}
}
sc.close();
}
private static boolean Menu() {
System.out.println("Welcome to media rental system");
System.out.println("1: Load Media objects ");
System.out.println("2: Find Media objects ");
System.out.println("3: Rent Media objects ");
System.out.println("9: exit ");
return true;
}
}

More Related Content

Similar to Question- Write the Java code below in IDE ECLIPSE enviroment and prov.docx

03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slotsmha4
 
Lecture java continued 1
Lecture java continued 1Lecture java continued 1
Lecture java continued 1Kamran Zafar
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptxarjun431527
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)Jay Patel
 
C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)Umar Farooq
 
Python-oop
Python-oopPython-oop
Python-oopRTS Tech
 
Lab 8 User-CF Recommender System – Part I 50 points .docx
Lab 8 User-CF Recommender System – Part I 50 points .docxLab 8 User-CF Recommender System – Part I 50 points .docx
Lab 8 User-CF Recommender System – Part I 50 points .docxsmile790243
 
Lecture java continued
Lecture java continuedLecture java continued
Lecture java continuedKamran Zafar
 
PRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comPRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comMcdonaldRyan108
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAVINASH KUMAR
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satyaSatya Johnny
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08Terry Yoast
 

Similar to Question- Write the Java code below in IDE ECLIPSE enviroment and prov.docx (20)

03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots03 object-classes-pbl-4-slots
03 object-classes-pbl-4-slots
 
Lecture java continued 1
Lecture java continued 1Lecture java continued 1
Lecture java continued 1
 
Unit4_2.pdf
Unit4_2.pdfUnit4_2.pdf
Unit4_2.pdf
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
I assignmnt(oops)
I assignmnt(oops)I assignmnt(oops)
I assignmnt(oops)
 
08ui.pptx
08ui.pptx08ui.pptx
08ui.pptx
 
C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)C# (This keyword, Properties, Inheritance, Base Keyword)
C# (This keyword, Properties, Inheritance, Base Keyword)
 
oops-1
oops-1oops-1
oops-1
 
Unit i
Unit iUnit i
Unit i
 
Python-oop
Python-oopPython-oop
Python-oop
 
Lab 8 User-CF Recommender System – Part I 50 points .docx
Lab 8 User-CF Recommender System – Part I 50 points .docxLab 8 User-CF Recommender System – Part I 50 points .docx
Lab 8 User-CF Recommender System – Part I 50 points .docx
 
Lecture java continued
Lecture java continuedLecture java continued
Lecture java continued
 
Smarttuts Project ppt
Smarttuts Project pptSmarttuts Project ppt
Smarttuts Project ppt
 
PRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.comPRG 421 Education Specialist / snaptutorial.com
PRG 421 Education Specialist / snaptutorial.com
 
Advanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sirAdvanced java jee material by KV Rao sir
Advanced java jee material by KV Rao sir
 
Programming homework
Programming homeworkProgramming homework
Programming homework
 
Adv kvr -satya
Adv  kvr -satyaAdv  kvr -satya
Adv kvr -satya
 
Advance java kvr -satya
Advance java  kvr -satyaAdvance java  kvr -satya
Advance java kvr -satya
 
9781439035665 ppt ch08
9781439035665 ppt ch089781439035665 ppt ch08
9781439035665 ppt ch08
 

More from HarryXQjCampbellz

Question 69 x Identify the vessels enclosed within the white box- Sele.docx
Question 69 x Identify the vessels enclosed within the white box- Sele.docxQuestion 69 x Identify the vessels enclosed within the white box- Sele.docx
Question 69 x Identify the vessels enclosed within the white box- Sele.docxHarryXQjCampbellz
 
Question- Ongoing discussions surround the implied right to privacy- P.docx
Question- Ongoing discussions surround the implied right to privacy- P.docxQuestion- Ongoing discussions surround the implied right to privacy- P.docx
Question- Ongoing discussions surround the implied right to privacy- P.docxHarryXQjCampbellz
 
QUESTION 5 Which of the following is the best definition of a Hypervis.docx
QUESTION 5 Which of the following is the best definition of a Hypervis.docxQUESTION 5 Which of the following is the best definition of a Hypervis.docx
QUESTION 5 Which of the following is the best definition of a Hypervis.docxHarryXQjCampbellz
 
Question 6 (Mandatory) (0-5 points) Saved Which of the following abou.docx
Question 6 (Mandatory) (0-5 points)  Saved Which of the following abou.docxQuestion 6 (Mandatory) (0-5 points)  Saved Which of the following abou.docx
Question 6 (Mandatory) (0-5 points) Saved Which of the following abou.docxHarryXQjCampbellz
 
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docx
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docxQuestion 5 5- The outer covering of a diatom is called a Time Elapsed-.docx
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docxHarryXQjCampbellz
 
Question 40 (bonus)- Which of the following is not a potential consequ.docx
Question 40 (bonus)- Which of the following is not a potential consequ.docxQuestion 40 (bonus)- Which of the following is not a potential consequ.docx
Question 40 (bonus)- Which of the following is not a potential consequ.docxHarryXQjCampbellz
 
QUESTION 4 When logical operating systems share the same physical reso.docx
QUESTION 4 When logical operating systems share the same physical reso.docxQUESTION 4 When logical operating systems share the same physical reso.docx
QUESTION 4 When logical operating systems share the same physical reso.docxHarryXQjCampbellz
 
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docx
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docxQuestion 4 (7 points) sived) Question A You are asked by Xavier- the a.docx
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docxHarryXQjCampbellz
 
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docx
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docxQUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docx
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docxHarryXQjCampbellz
 
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docx
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docxQuestion 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docx
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docxHarryXQjCampbellz
 
Question 3- Budgets are the primary instrument managers use for planni.docx
Question 3- Budgets are the primary instrument managers use for planni.docxQuestion 3- Budgets are the primary instrument managers use for planni.docx
Question 3- Budgets are the primary instrument managers use for planni.docxHarryXQjCampbellz
 
Question 3) Find the maximum likelihood estimates for and for 2 if a.docx
Question 3) Find the maximum likelihood estimates for  and for 2 if a.docxQuestion 3) Find the maximum likelihood estimates for  and for 2 if a.docx
Question 3) Find the maximum likelihood estimates for and for 2 if a.docxHarryXQjCampbellz
 
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docx
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docxQuestion 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docx
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docxHarryXQjCampbellz
 
Question 3 20 pts For each of the following- is it an example of inves.docx
Question 3 20 pts For each of the following- is it an example of inves.docxQuestion 3 20 pts For each of the following- is it an example of inves.docx
Question 3 20 pts For each of the following- is it an example of inves.docxHarryXQjCampbellz
 
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docx
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docxR-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docx
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docxHarryXQjCampbellz
 
R is a powerful programming language- What are the benefits of using s.docx
R is a powerful programming language- What are the benefits of using s.docxR is a powerful programming language- What are the benefits of using s.docx
R is a powerful programming language- What are the benefits of using s.docxHarryXQjCampbellz
 
quick review to see what you've learned so far- answer the follewing q.docx
quick review to see what you've learned so far- answer the follewing q.docxquick review to see what you've learned so far- answer the follewing q.docx
quick review to see what you've learned so far- answer the follewing q.docxHarryXQjCampbellz
 
Quevtion Z II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docx
Quevtion Z  II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docxQuevtion Z  II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docx
Quevtion Z II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docxHarryXQjCampbellz
 
Quick ratio Adieu Company reported the following current assets and cu.docx
Quick ratio Adieu Company reported the following current assets and cu.docxQuick ratio Adieu Company reported the following current assets and cu.docx
Quick ratio Adieu Company reported the following current assets and cu.docxHarryXQjCampbellz
 

More from HarryXQjCampbellz (20)

Question 69 x Identify the vessels enclosed within the white box- Sele.docx
Question 69 x Identify the vessels enclosed within the white box- Sele.docxQuestion 69 x Identify the vessels enclosed within the white box- Sele.docx
Question 69 x Identify the vessels enclosed within the white box- Sele.docx
 
Question- Ongoing discussions surround the implied right to privacy- P.docx
Question- Ongoing discussions surround the implied right to privacy- P.docxQuestion- Ongoing discussions surround the implied right to privacy- P.docx
Question- Ongoing discussions surround the implied right to privacy- P.docx
 
QUESTION 5 Which of the following is the best definition of a Hypervis.docx
QUESTION 5 Which of the following is the best definition of a Hypervis.docxQUESTION 5 Which of the following is the best definition of a Hypervis.docx
QUESTION 5 Which of the following is the best definition of a Hypervis.docx
 
Question 6 (Mandatory) (0-5 points) Saved Which of the following abou.docx
Question 6 (Mandatory) (0-5 points)  Saved Which of the following abou.docxQuestion 6 (Mandatory) (0-5 points)  Saved Which of the following abou.docx
Question 6 (Mandatory) (0-5 points) Saved Which of the following abou.docx
 
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docx
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docxQuestion 5 5- The outer covering of a diatom is called a Time Elapsed-.docx
Question 5 5- The outer covering of a diatom is called a Time Elapsed-.docx
 
Question 40 (bonus)- Which of the following is not a potential consequ.docx
Question 40 (bonus)- Which of the following is not a potential consequ.docxQuestion 40 (bonus)- Which of the following is not a potential consequ.docx
Question 40 (bonus)- Which of the following is not a potential consequ.docx
 
QUESTION 4 When logical operating systems share the same physical reso.docx
QUESTION 4 When logical operating systems share the same physical reso.docxQUESTION 4 When logical operating systems share the same physical reso.docx
QUESTION 4 When logical operating systems share the same physical reso.docx
 
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docx
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docxQuestion 4 (7 points) sived) Question A You are asked by Xavier- the a.docx
Question 4 (7 points) sived) Question A You are asked by Xavier- the a.docx
 
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docx
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docxQUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docx
QUESTION 3Suppose the average AGE of the sample is 42-20 years with a.docx
 
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docx
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docxQuestion 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docx
Question 38 (bonus)- True or False- Over the last 800-000 years- CO2 l.docx
 
Question 3- Budgets are the primary instrument managers use for planni.docx
Question 3- Budgets are the primary instrument managers use for planni.docxQuestion 3- Budgets are the primary instrument managers use for planni.docx
Question 3- Budgets are the primary instrument managers use for planni.docx
 
Question 3) Find the maximum likelihood estimates for and for 2 if a.docx
Question 3) Find the maximum likelihood estimates for  and for 2 if a.docxQuestion 3) Find the maximum likelihood estimates for  and for 2 if a.docx
Question 3) Find the maximum likelihood estimates for and for 2 if a.docx
 
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docx
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docxQuestion 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docx
Question 3 3Peints Much the adrenerge meceptor ta the coriect locacon.docx
 
Question 3 20 pts For each of the following- is it an example of inves.docx
Question 3 20 pts For each of the following- is it an example of inves.docxQuestion 3 20 pts For each of the following- is it an example of inves.docx
Question 3 20 pts For each of the following- is it an example of inves.docx
 
r-6-5--t-30 years.docx
r-6-5--t-30 years.docxr-6-5--t-30 years.docx
r-6-5--t-30 years.docx
 
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docx
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docxR-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docx
R-4-17 Show that if d(n) is O(f(n)) and e(n) is O(g(n))- then d(n)e(n).docx
 
R is a powerful programming language- What are the benefits of using s.docx
R is a powerful programming language- What are the benefits of using s.docxR is a powerful programming language- What are the benefits of using s.docx
R is a powerful programming language- What are the benefits of using s.docx
 
quick review to see what you've learned so far- answer the follewing q.docx
quick review to see what you've learned so far- answer the follewing q.docxquick review to see what you've learned so far- answer the follewing q.docx
quick review to see what you've learned so far- answer the follewing q.docx
 
Quevtion Z II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docx
Quevtion Z  II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docxQuevtion Z  II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docx
Quevtion Z II 45 AFID per tirket- 1- Auk tae mer about teeir lype of.docx
 
Quick ratio Adieu Company reported the following current assets and cu.docx
Quick ratio Adieu Company reported the following current assets and cu.docxQuick ratio Adieu Company reported the following current assets and cu.docx
Quick ratio Adieu Company reported the following current assets and cu.docx
 

Recently uploaded

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Recently uploaded (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

Question- Write the Java code below in IDE ECLIPSE enviroment and prov.docx

  • 1. Question: Write the Java code below in IDE ECLIPSE enviroment and provide screenshots of the execution. Project Media Rental System Before attempting this project, be sure you have completed all of the reading assignments, non- graded exercises, examples, discussions, and assignments to date. Design and implement Java program as follows: 1) Media hierarchy: Create Media, EBook, MovieDVD, and MusicCD classes from Week 3 -> Practice Exercise - Inheritance solution. Add an attribute to Media class to store indication when media object is rented versus available. Add code to constructor and create get and set methods as appropriate. Add any additional constructors and methods needed to support the below functionality 2) Design and implement Manager class which (Hint: check out Week 8 Reading and Writing files example): stores a list of Media objects has functionality to load Media objects from files creates/updates Media files has functionality to add new Media object to its Media list has functionality to find all media objects for a specific title and returns that list has functionality to rent Media based on id (updates rental status on media, updates file, returns rental fee) 3) Design and implement MediaRentalSystem which has the following functionality: user interface which is either menu driven through console commands or GUI buttons or menus. Look at the bottom of this project file for sample look and feel. (Hint: for command-driven menu check out Week 2: Practice Exercise - EncapsulationPlus and for GUI check out Week 8: Files in GUI example) selection to load Media files from a given directory (user supplies directory) selection to find a media object for a specific title value (user supplies title and should display to user the media information once it finds it - should find all media with that title) selection to rent a media object based on its id value (user supplies id and should display rental fee value to the user) selection to exit program 4) Program should throw and catch Java built-in and user-defined exceptions as appropriate 5) Your classes must be coded with correct encapsulation: private/protected attributes, get methods, and set methods and value validation 6) There should be appropriate polymorphism: overloading, overriding methods, and dynamic binding 7) Program should take advantage of the inheritance properties as appropriate Expert Answer
  • 2. This solution was written by a subject matter expert. It's designed to help students like you learn core concepts. SOLUTION- Note :- I have solve the problem in Java code if you have any doubt just let me know import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; class Media { int id; String title; int year, chapter; boolean available; Media() { } public Media(int id, String title, int year, int chapter, boolean available) { this.id = id; this.title = title; this.year = year; this.chapter = chapter; this.available = available; } public int getId() {
  • 3. return id; } public void setId(int id) { this.id = id; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } public int getChapter() { return chapter; } public void setChapter(int chapter) { this.chapter = chapter; }
  • 4. public boolean isAvailable() { return available; } public void setAvailable(boolean available) { this.available = available; } } class EBook extends Media { EBook(int id, String title, int year, int chapter, boolean available) { super(id, title, year, chapter, available); } @Override public String toString() { return "EBook [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" + this.year + " available:" + this.available + "]n"; } } class MovieDVD extends Media { MovieDVD(int id, String title, int year, int chapter, boolean available) { super(id, title, year, chapter, available); } @Override public String toString() {
  • 5. return "MovieDVD [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" + this.year + " available:" + this.available + "]n"; } } class MusicCD extends Media { MusicCD(int id, String title, int year, int chapter, boolean available) { super(id, title, year, chapter, available); } @Override public String toString() { return "MusicCD [id:" + this.id + " title:" + this.title + " chapter:" + this.chapter + " year:" + this.year + " available:" + this.available + "]n"; } } class Manager { static List<Media> list=new ArrayList<>();; Manager() { } public boolean LoadMedia(String path) { try { File myObj = new File(path); Scanner myReader = new Scanner(myObj);
  • 6. while (myReader.hasNextLine()) { String data = myReader.nextLine(); String[] str = data.split(" "); if (str[0].equals("EBook")) { list.add(new EBook(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]), Integer.parseInt(str[4]), Boolean.parseBoolean(str[5]))); }else if(str[0].equals("MusicCD")) { list.add(new MusicCD(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]), Integer.parseInt(str[4]), Boolean.parseBoolean(str[5]))); }else { list.add(new MovieDVD(Integer.parseInt(str[1]), str[2], Integer.parseInt(str[3]), Integer.parseInt(str[4]), Boolean.parseBoolean(str[5]))); } } System.out.println(list); myReader.close(); return true ; } catch (FileNotFoundException e) { System.out.println("An error occurred."); e.printStackTrace(); return false; } }
  • 7. public void findMedia(String title) { for(Media m : list) { if(m.getTitle().equals(title)) System.out.print(m.toString()); } } public void rentMedia(int id) { for(Media m : list ) { if(m.getId()==id) { if(m.isAvailable()) System.out.println("media successfully rented out "); else System.out.println("Media with id="+id+" is not available for rent "); } } } } public class MediaRentalSystem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (Menu()) { int choice = 0; System.out.println("Enter choice");
  • 8. choice = sc.nextInt(); Manager m = new Manager(); switch (choice) { case 1: //String path = "C:UsersAdminDocumentsworkspace-spring-tool-suite-4- 4.9.0.RELEASECore-Javasrcmedia.txt"; System.out.println("Enter file path load media "); String path=sc.next(); m.LoadMedia(path); break; case 2: System.out.println("Enter media title "); String title=sc.next(); m.findMedia(title); break; case 3: System.out.println("Enter media id :"); int id =sc.nextInt(); m.rentMedia(id); break; case 9: System.exit(0); break; default:
  • 9. System.out.println("Enter valid choice "); break; } } sc.close(); } private static boolean Menu() { System.out.println("Welcome to media rental system"); System.out.println("1: Load Media objects "); System.out.println("2: Find Media objects "); System.out.println("3: Rent Media objects "); System.out.println("9: exit "); return true; } }