Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming Assignment Can someone help me with this assignment, please see below Let's have fun with Exceptions, IO, and serialization! (not a phrase you

Java Programming Assignment

Can someone help me with this assignment, please see below

Let's have fun with Exceptions, IO, and serialization! (not a phrase you hear every day...)

You will write two classes:

* RollerDerbyPlayer

* RollerDerbyTeam

For any method that does IO, make sure to try/catch any relevant IO Exceptions.

Both classes will implement the Serializable interface. Give both classes a toString method so you can print out the entire team to check it. The team has multiple players stored as a private ArrayList 'players'. Your RollerDerbyTeam will have a static method loadTeam(String filename) that uses the Scanner class to parse each player from the below file (roller_derby_team.csv), create a player object for each player, and save them in the private arrayList 'players'.

load this file into the team: roller_derby_team.csvimage text in transcribed

The file format is: firstName, lastName, ageYears, heightFeet, heightInches, approxWeight

You've accomplished step 1 -- load the team from the CSV file. The next step is to serialize the team into a binary file. Use the FileOutputStream and ObjectOutputStream classes to write the entire team to the file "roller_derby_objects". Create a new method called serializeTeam(String filename) in your RollerDerbyTeam class to do this.

You've accomplished step 2 -- serialize the team object including all the players to disk. Note that you only have to serialize the team and the players come with it.

Next you'll write a static method in our RolllerDerbyTeam class, void deSerializeTeam(String filename) that uses ObjectInputStream and FileInputStream to load the contents of the file as a team object and return a new RollerDerbyTeam (like loadTeam() does).

You've accomplished step 3 -- deSerialize the team from disk!

For the final stage, create a method writeTeam(String filename) in your team class that writes out each player to a file called 'roller_derby_team.csv'. You'll utilize the PrintWriter and File classes and call println() to write out each line. You can create a method in the player class called toCSV() that returns the player as a comma separated value string to help you out. Then just loop over all players and call the toCSV and println() it to the file.

WHen you're finished you should have produced in the final step (step 4), an identical CSV file to the one you started with.

You went from CSV file -> object -> serialized object -> object -> CSV file.

When you submit your assignment include the .java file as well as the final .CSV file and a screenshot of the output of the program.

roller_derby_team.csv File

Ibrahim, Moizoos, 24, 5, 6, 175

Davoin, Shower-Handel, 22, 5, 7, 154

Hingle, McCringleberry, 30, 6, 1, 168

Swirvithan, L'Goodling-Splatt, 28, 5, 10, 220

Jackmerius, Tacktheritrix, 40, 6, 2, 201

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

More Books

Students also viewed these Databases questions