Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your customer is desperate. He owns the program code of a class person as well as a file friends.dat. Friends.dat contains serialized byte sequences of

Your customer is desperate. He owns the program code of a class person as well as a file friends.dat. Friends.dat contains serialized byte sequences of various person objects. Your customer does not know how to "bring the byte sequences back to life" (activated). He wants to know what people are in the friends.dat file and what the friendship relationships between them look like. Your customer knows that the friends.dat file contains a single ArrayList object. Here is the source code of the class Person (in the anonymous default package):

image text in transcribed

You get the class Person in the source code as well as the file friends.dat as an attachment to this task. Create a static decode method in the Decode class (in the anonymous default package) that deserializes the file given as the filename parameter and then prints out the friendships in the order they appear in the deserialized ArrayList. The desired output format is as follows (where the file friends.dat contains other than the following personal data): Hans mag Frieda Berta mag Fritz Frieda mag Hans Fritz mag Fritz

1 import java.io.Serializable; 3 public class Person implements Serializable 4 private static final long serialVersionUID1L; private String name; private Person bestFriend; 6 public Person(String name) 9 this.namename; 2 public void setBestFriend (Person friend) i this.bestFriend-friend; 14 public Person getBestFriend() return bestFriend; 18 19 public String getName()[ return name; Override 5 public String toString()5 26 return name "( bestFriend.name+ ")"; 27 28

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

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

15.7 Explain the six steps in the termination interview

Answered: 1 week ago

Question

13. You always should try to make a good first impression.

Answered: 1 week ago