Ditutup

File Handling in Java

Write a program, which imitates a simple organizer. This organizer will be used to create, keep, view and delete names, phone numbers and birthdates of your friends. The information must be stored in the file “[url removed, login to view]”.

Task A

Create a design for your program from the following specifications:

• class Person which contains the fields for name, surname, phone number, date of birth. Also the class must contain a non-static method “public int compareTo(Person p)” that compares lexicographically full names of the current person object you called the method on and the person p which is passed as a parameter to the method. It should return +1, 0, or –1 depending on whether the current person’s name comes earlier, is the same or comes later in the lexicographical order as that of the parameter p.

• class Date, objects of which represent dates. It must contain three integer fields for day, month, and year. Also the class must contain a non-static method “public int compareTo(Date d)” that compares the date represented by the current date object you called the method on with the date represented by the parameter passed to the method. It should return +1, 0, or –1 depending on whether the current date is earlier, is the same or is later then the date represented by the parameter p.

Both classes must implement Serializable interface. The compareTo methods are used for sorting.

Task B

Create a class Organizer (extends JFrame), which opens the file “[url removed, login to view]” (if the file does not exist program must create it) and outputs information stored in the file in the following Organizer:

All Person objects stored in the file “[url removed, login to view]” are displayed in JList with scrollbar. When you choose some element from the JList, information about corresponding person displays in the form. You can sort persons either by Full Name (lexicographically) or by Date of Birth clicking appropriate radio buttons. You also can delete several items from the JList by clicking the Delete button. You can undo the last delete by clicking the Undo button.

If you close the form (by clicking either the Close button or x button), current information will be written to “[url removed, login to view]” file.

To input information about a person you must click the “Create Entry” button in the Organizer. In this case the following modal JDialog “Input Form” appears on the screen (class InputDialog extending JDialog). You can fill the text fields of the form with the information of the person.

If everything is correct click Write, otherwise click Cancel. In both cases all text fields become clear, but in the first case information is stored, in the second is discarded.

Clicking the Close button or x-button of the “Input Form” makes the dialog invisible, and all the changes made are displayed in the “View Form”.

Note:- GUI images for the project attached in a word document. Just have a look.

This program must be done in Eclipse.

Kemahiran: Java

Lihat lebih lanjut: file handling java, java file handling dat, three p, static interface, sorting method, gui number, first class objects in java, does c have classes, design your phone case, java file handling methods, project file handling java, word file handling java, dat file jlist, fill in form word, delete button, word p, Modal, java file, java file handling, int, input method, file, dat entry, d java, cases

Tentang Majikan:
( 2 ulasan ) Ahmedabad, India

ID Projek: #65784