Question

In: Computer Science

A University Library has many items available for its students; some can be checked out and...

A University Library has many items available for its students; some can be checked out and others cannot. Among those that can be checked out are journal (i.e., a literary journal) and digital video disk (i.e., a DVD). These two types have many attributes in common such as title, publisher, and dewey decimal classification. Design a class to represent the library item that would capture the common features among journals and DVDs. Then, design journal and digital video classes that are derived from the library item base class. If you feel confident enough to draw a UML class diagram depicting the classes, then feel free to do so. Otherwise, you can submit something like the following for each class The library item class does not need more attributes, but you should add at least 2 methods to the class. The journal and digital video classes should have at least 3 attributes and at least 2 methods.

The library item class does not need more attributes (you can use the ones provided, if you like), but you should add at least 2 methods to the class. The journal and digital video classes should have at least 3 attributes and at least 2 methods.

If you feel confident enough to draw a UML class diagram depicting the classes, then feel free to do so.

Deliverable

1) Implement your UML diagram into Java code for all 3 classes.

2) Create a driver class to test that your class design works. (Upload all 3 class files along with your driver class)

Solutions

Expert Solution

Deliverable

1) Implement your UML diagram into Java code for all 3 classes.

Content of the Library.java file

import java.util.Scanner;
public class Library
{
   String title,publisher;
   int DDC;
   void setInfo()
   {
       Scanner sc= new Scanner(System.in);
       System.out.print("Enter the title of the item: ");
       title= sc.nextLine();
       System.out.print("Enter the publisher of the item: ");
       publisher= sc.nextLine();
       System.out.print("Enter the DDC of the item: ");
       DDC= sc.nextInt();   
   }
   void display()
   {
       System.out.println("The title of the item is" + title);  
       System.out.println("The publisher of the item is" + publisher);  
       System.out.println("The DDC of the item is" + DDC);  
   }
}

Content of the Journal.java file

import java.util.Scanner;
public class Journal extends Library
{
   int cost,volume,issue;
   void setInfo()
   {
       super.setInfo();
       Scanner sc= new Scanner(System.in);
       System.out.print("Enter the cost of the journal: ");
       cost= sc.nextInt();
       System.out.print("Enter the volume of the journal: ");
       volume= sc.nextInt();
       System.out.print("Enter the issue of the journal: ");
       issue= sc.nextInt();   
   }
   void display()
   {
       super.display();
       System.out.println("The cost of the journal is" + cost);  
       System.out.println("The volume of the journal is" + volume);  
       System.out.println("The issue of the journal is" + issue);  
   }
}

Content of the DigVideo.java file

import java.util.Scanner;
public class DigVideo extends Library
{
   int cost,size,issue;
   void setInfo()
   {
       super.setInfo();
       Scanner sc= new Scanner(System.in);
       System.out.print("Enter the cost of the digital video: ");
       cost= sc.nextInt();
       System.out.print("Enter the size of the digital video: ");
       size= sc.nextInt();
       System.out.print("Enter the length of the digital video: ");
       issue= sc.nextInt();   
   }
   void display()
   {
       super.display();
       System.out.println("The cost of the digital video is" + cost);  
       System.out.println("The size of the digital video is" + size);  
       System.out.println("The length of the digital video is" + issue);  
   }
}

Deliverable

2) Create a driver class to test that your class design works. (Upload all 3 class files along with your driver class)

Content of the Driver.java file

class Driver
{
   public static void main(String args[])
   {
       Journal j= new Journal();
       DigVideo d = new DigVideo();
       System.out.println("Information of Journal Item");
       j.setInfo();
       System.out.println();
       System.out.println();
       System.out.println("Information of Digital Video Item");
       d.setInfo();
       System.out.println("\n\n Entered intormation of the Journal is ");
       j.display();
       System.out.println("\n\n Entered intormation of the Digital Video is ");
d.display();
   }
}

*Note

The solution contains content of four files. Keep all thee file in same directory. use the following command to execute the code.

>>>javac Library.java

>>>javac Journal.java

>>>javac DigVideo.java

>>>javac Driver.java

>>>java Driver

Sample Input and Output:


Related Solutions

A county library in Minnesota reported the following number of books checked out in 15 randomly...
A county library in Minnesota reported the following number of books checked out in 15 randomly selected months: 5,176 6,005 5,052 5,310 4,188 4,132 5,736 5,381 4,983 4,423 5,002 4,573 4,209 5,611 4,568 Determine the range, variance, and standard deviation for the sample data.
What are some of the available commands that can be utilized in R for carrying out...
What are some of the available commands that can be utilized in R for carrying out a one-sample and two-sample t-test? What are the differences between carrying out a t-test with equal and unequal variance? Please provide an example to illustrate your assertions.
A university has found over the years that out of all the students who are offered...
A university has found over the years that out of all the students who are offered admission, the proportion who accept is 0.70. After a new director of admissions is hired, the university wants to check if the proportion of students accepting has changed significantly. Suppose they offer admission to 1200 students and 888 accept. Is this evidence at the α = .05 level that there has been a real change from the status quo?
A North Carolina university wants to determine how many of its graduating students go on to...
A North Carolina university wants to determine how many of its graduating students go on to find gainful employment in their field of study. After sampling 200 students from the previous graduating class, they find that 174 of them are employed in a related field. Using this information, construct the 90% confidence interval for the amount of students that will go on to be employed in their field.
What has change about the type of available resources in the library today vs library of...
What has change about the type of available resources in the library today vs library of the past?
A local university wants to conduct a sample of 200 students out of 6000 students. We...
A local university wants to conduct a sample of 200 students out of 6000 students. We can assume that the university maintains a good roster of all registered students. (1) how would you select the 200 students(a) using simple random sample method and (b) systematic sampling method? (2) suppose that the university administration wants to make sure in particular students who major in music (a small department with only 8% of students major in music)be adequately included in your sample,...
A student wants to see if the number of times a book has been checked out...
A student wants to see if the number of times a book has been checked out of the library in the past year and the number of pages in the book are related. She guesses that the number of times a book has been checked out of the library in the past year will be a predictor of the number of pages it has. She randomly sampled 14 books from the library, test her claim at a 0.10 level of...
A student wants to see if the number of times a book has been checked out...
A student wants to see if the number of times a book has been checked out of the library in the past year and the number of pages in the book are related. She guesses that the number of times a book has been checked out of the library in the past year will be a predictor of the number of pages it has. She randomly sampled 15 books from the library, test her claim at a 0.01 level of...
A student wants to see if the number of times a book has been checked out...
A student wants to see if the number of times a book has been checked out of the library in the past year and the number of pages in the book are related. She guesses that the number of times a book has been checked out of the library in the past year will be a predictor of the number of pages it has. She randomly sampled 15 books from the library, test her claim at a 0.01 level of...
A student wants to see if the number of times a book has been checked out...
A student wants to see if the number of times a book has been checked out of the library in the past year and the number of pages in the book are related. She guesses that the number of times a book has been checked out of the library in the past year will be a predictor of the number of pages it has. She randomly sampled 14 books from the library, test her claim at a 0.05 level of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT