Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Clear please. Q 1. Implement the following in Java: a Create a data type Person with three string fields: firstName, lastname and id. The field

Clear please.
image text in transcribed
Q 1. Implement the following in Java: a Create a data type Person with three string fields: firstName, lastname and id. The field id is unique to each person. Add accessor methods, a constructor with three parameters, and the toString() method. b Within the main() program, instantiate a linked list (use the Java LinkedList class). Write the following functions(methods) that the main program will invoke all these will be static methods of the main class): store (, ) that reads the data for several persons from the input stream and stores the data in the linked list. display (output stream>, ) that writes the data for all person ob- jects in the linked list, on the output stream, one per line. find(string sid, ) that returns the index of the person object in the linked list, that has the same id value as sid (return -1 if no such person exists). This can be done as a simple search that goes sequentially through all the objects in the linked list. Create a data file with data for a few person objects. In the main method, call the store) and display() methods to read the data and display it. Invoke the find method a few times. Compile and test your code. c Construct a different version of the above program as follows: (1) create a data type Personlist that uses the Java Linkedlist, and supports the methods(re- written appropriately) from part b. (2) instantiate the PersonList object in the main program and invoke its methods (as per the appropriate syntax), so that program produces the same output as the one in part b. 1

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions