Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

How do you write the code for mainDVDFile.java according the requirements below in Java? The TestObjectInputStream and OutputStream are sample code and does not match

How do you write the code for mainDVDFile.java according the requirements below in Java?

The TestObjectInputStream and OutputStream are sample code and does not match the requirements

I need help writing the program for Part 3, according to the requirements

I have part 1 , finished

part 2, maybe correct

part 3 not correct

part 4 I have sample code, my next question

I have included my code below:

Class 3 Chapter 17 Lab( Store objects in a file)

Due Wednesday by 6pm Points 10 Submitting a text entry box, a website url, or a file upload Available Feb 8 at 6pm - Feb 15 at 6pm

Program 3.2 Requirements

Part 1: Maven

Generate a maven project and import it into Eclipse like we did in class. Use the java11-junit5 archetype, the group should be com.jccc.objects.file and the name of the project is objects-file. Take a screenshot of eclipse showing the included project. The project should be expanded, so the folders can be seen. upload the pom.xml and screenshot as part of the this lab.

Part 2 -- create an object

DVDs. The DVDs have 3 attributes: name -- 32 bytes length of film -- 5 bytes MPAA rating -- 2 bytes

Part 3 -- Write a program

The main method of the program should just call the 4 methods below Create a method that creates a List of 5 DVD. The DVD can be whatever you like but must contain all 3 attributes. Write a method Using Object Streams that stores the List of DVDs(use the method above). a Date object for the current time, and the double value 5.5 into a file named class03Object.dat. Write a method Using Object Streams that reads the data from class03Object.dat. The method returns a List Write a method using RandomAccessFile that stores the List of DVDs(use the method above) into a file named class03RAF.dat. Write a method Using RandomAccessFile that reads the data from class03RAF.dat. The method returns a List

Part 4 -- Write Junit tests --Reminder Test files should have the same name as the file that they are testing plus the ending Test

write a Junit test method that calls the write method Using Object Streams and then call the read method and assert the values read. write a second Junit test method that calls the write method Using RandomAccessFile and then call the read method and assert the values read.

Expected Documentation

JavaDoc with @author and your name and a brief description of the class. Also, each method should have Javadoc on it. Checkstyle must be used. Not using Checkstyle will be an automatic loss of 10%.

Submission

Upload the files for each part to this lab submission page. There should be 5 files.

DVD.java

package com.jccc.objects.file;

public class DVD { private String name; private String lengthOfFilm; private String rating; public DVD(String name, String lengthOfFilm, String rating) { super(); this.name = name; this.lengthOfFilm = lengthOfFilm; this.rating = rating; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getLengthOfFilm() { return lengthOfFilm; } public void setLengthOfFilm(String lengthOfFilm) { this.lengthOfFilm = lengthOfFilm; } public String getRating() { return rating; } public void setRating(String rating) { this.rating = rating; }

}

mainDVDFile.java

package com.jccc.objects.file;

import java.util.ArrayList; import java.util.List; import java.io.*;

public class mainDvdFile {

public String DVD() { DVD movie1 = new DVD ("Kung Fu Panda", "65", "PG" ); DVD movie2 = new DVD ("Karate Kid", "90", "PG-13"); DVD movie3 = new DVD("Ice Age", "85", "PG"); DVD movie4 = new DVD("Titanic", "89", "R" ); DVD movie5 = new DVD("Spiderman", "75", "R"); } // I am not sure if correct below ? public List Listof5DVDs() { ArrayList DVD2 = new ArrayList<>(); DVD2.add("name", "length of film", "rating"); } public static void main(String[] args) { } // This code is not an example below, I need something that will match the requirements

public class TestObjectOutputStream { try ( // Create an output stream for file object.dat ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream("class03RAF.dat")); ) { // Write a string, double value, and object to the file output.writeUTF("John"); output.writeDouble(85.5); output.writeObject(new java.util.Date()); } } // this code is an example, I need something that will match the requirements public List TestObjectInputStream() throws ClassNotFoundException, IOException { try ( // Create an input stream for file object.dat ObjectInputStream input = new ObjectInputStream(new FileInputStream("class03Object.dat")); ) { // Read a string, double value, and object from the file String name = input.readUTF(); double score = input.readDouble(); java.util.Date date = (java.util.Date)(input.readObject()); System.out.println(name + " " + score + " " + date); } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

What is one of the skills required for independent learning?Explain

Answered: 1 week ago