Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Greetings, this is a small assignment for Java. it is more than one question. Please let me know if its possible to submit it on

Greetings,

this is a small assignment for Java. it is more than one question. Please let me know if its possible to submit it on parts for better results. Thank you in Advance

image text in transcribed

Implement the Java application following the given restrictions. Other than the given constraints, you are free in your implementation. The project is divided into phases. Make sure you implement the phases in the order given Phase 1: Design the following classes: An abstract University Person. Concrete Student, Staff, Faculty, Undergrad, Graduate classes. Each concrete sub class will have a unique number that ranges between 0 and 255. UniversityPerson is the top of the hierarchy of classes whose sub classes are Student, Staff and Faculty. Undergrad and Graduate inherit from the Student class. UniversityPerson has firstName and lastName properties. Create default no-arg and parametirzed constructors. This class also has a static method called search that takes last name and will do search records if its subclass objects. The UniversityPerson class has an abstract method called read that is overriden by all sub classes of it. And it returns a reference to an object of type UniversityPerson. All sub classes of UniversityPerson override the toString method that prints the object's data in a nicely formatted way. Phase 2: When the application starts in your main method) open the file which contains all the objects' (of UnversityPerson) saved states and read them into a list of UniversityPerson type. That is, all the objects saved before into the binary file will be stored in an in-memory data type (list). Your application should work with this in-memory objects. When you are using/testing your application the first time, you probably will not have such a file (since you have not worked with subtype objects yet). If that file does not exist, then you should create an empty list. Once you add new object references to this list, saving or exiting the application will create that file with the objects'states. After the first time, opening the file should read all the objects saved before. All the modifications/updates/deletions/additions to objects should be made in the in-memory data structure. If you want to save your objects or exit, your application should save the in-memory data structure to the random access file. The write method of subtypes of UniversityPerson should first write a single-byte unique number that identifies the type. All the data of the concrete subtypes should be written using methods of the FileOutputStream class. The string would be a bit different since you need to specify how many bytes the string would be (remember that first and last names are strings). Use a two-byte integer to store the string length followed by the actual string. Create a text file where you will save user names and their passwords. The user names will be stored as plain text, that is, no encryption is used. Only the hashes of passwords are saved this text file. The user name and password should be separated by a delimiter of your choice and they are stored on a line by itself in the file. In this phase you provide a menu to the user if they want to login or register. Registering a user would append a user name and his/her hash to the file. If a user wants to login then your app should get the user name and his/her password and compare if that user name with its password's hash are in the file. Successful login allows users to use the system. Otherwise, the user will be warned that user name and/or password is wrong. Phase 3: Design user interface plate for Your application, after successful login, should give the user the opportunity to add/delete/update/search any subtype object by its last name. You can freely choose and degisn UI for all phases of your Project. More explanation: Let me try to describe the main points of the project here. First of all, when application starts, you will give a menu to the user if they want to login or register. After a successful login, the app should "load" the binary data file into a list of University Person type. That is, all the objects of different type should be saved in their respective objects in the list. Reading should be done polymorphically. Each object's data is preceded by the single byte that denotes the type of the object. You can read this byte first and then use this as an index into an array of type UniversityPerson which populated with different object references. For example, if you choose to use 0 (zero) for the Faculty type then you should have a reference to an object of type Faculty in the array. Each object type (Faculty, Staff, Undergrad, and Grad) knows how to write and read into the binary file. All operations (delete, update, add, search by some property) should be done using the in-memory list. Before exiting the application, you should save the list into the binary file again. Implement the Java application following the given restrictions. Other than the given constraints, you are free in your implementation. The project is divided into phases. Make sure you implement the phases in the order given Phase 1: Design the following classes: An abstract University Person. Concrete Student, Staff, Faculty, Undergrad, Graduate classes. Each concrete sub class will have a unique number that ranges between 0 and 255. UniversityPerson is the top of the hierarchy of classes whose sub classes are Student, Staff and Faculty. Undergrad and Graduate inherit from the Student class. UniversityPerson has firstName and lastName properties. Create default no-arg and parametirzed constructors. This class also has a static method called search that takes last name and will do search records if its subclass objects. The UniversityPerson class has an abstract method called read that is overriden by all sub classes of it. And it returns a reference to an object of type UniversityPerson. All sub classes of UniversityPerson override the toString method that prints the object's data in a nicely formatted way. Phase 2: When the application starts in your main method) open the file which contains all the objects' (of UnversityPerson) saved states and read them into a list of UniversityPerson type. That is, all the objects saved before into the binary file will be stored in an in-memory data type (list). Your application should work with this in-memory objects. When you are using/testing your application the first time, you probably will not have such a file (since you have not worked with subtype objects yet). If that file does not exist, then you should create an empty list. Once you add new object references to this list, saving or exiting the application will create that file with the objects'states. After the first time, opening the file should read all the objects saved before. All the modifications/updates/deletions/additions to objects should be made in the in-memory data structure. If you want to save your objects or exit, your application should save the in-memory data structure to the random access file. The write method of subtypes of UniversityPerson should first write a single-byte unique number that identifies the type. All the data of the concrete subtypes should be written using methods of the FileOutputStream class. The string would be a bit different since you need to specify how many bytes the string would be (remember that first and last names are strings). Use a two-byte integer to store the string length followed by the actual string. Create a text file where you will save user names and their passwords. The user names will be stored as plain text, that is, no encryption is used. Only the hashes of passwords are saved this text file. The user name and password should be separated by a delimiter of your choice and they are stored on a line by itself in the file. In this phase you provide a menu to the user if they want to login or register. Registering a user would append a user name and his/her hash to the file. If a user wants to login then your app should get the user name and his/her password and compare if that user name with its password's hash are in the file. Successful login allows users to use the system. Otherwise, the user will be warned that user name and/or password is wrong. Phase 3: Design user interface plate for Your application, after successful login, should give the user the opportunity to add/delete/update/search any subtype object by its last name. You can freely choose and degisn UI for all phases of your Project. More explanation: Let me try to describe the main points of the project here. First of all, when application starts, you will give a menu to the user if they want to login or register. After a successful login, the app should "load" the binary data file into a list of University Person type. That is, all the objects of different type should be saved in their respective objects in the list. Reading should be done polymorphically. Each object's data is preceded by the single byte that denotes the type of the object. You can read this byte first and then use this as an index into an array of type UniversityPerson which populated with different object references. For example, if you choose to use 0 (zero) for the Faculty type then you should have a reference to an object of type Faculty in the array. Each object type (Faculty, Staff, Undergrad, and Grad) knows how to write and read into the binary file. All operations (delete, update, add, search by some property) should be done using the in-memory list. Before exiting the application, you should save the list into the binary file again

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