Posted by : Anonymous Saturday 27 April 2013

Question:                                                                                              

You have to develop a simple console base application, which reads an input from the user and based on user input, insert different information in different text files and also display on console.


Solution Guidelines:

    Create Emplyee.java which will contain employee information (id, name, Joining Date, Designation, Address, Phone number and email address). Constructor and setter/ getter functions implementation should be defined in the Employee class.
     Create LabourCard.java which will contain labourcard information (Id, EmpId, IssueDate, ExpiryDate). Constructor and setter/ getter functions implementation should be defined in the LabourCard class.
    Create HealthCard.java which will contain healthcard information (Id, EmpId, IssueDate, ExpiryDate). Constructor and setter/ getter functions implementation should be defined in HealthCard class.
    Create Driver.java which will contain your main program. In the main program you are required to initialize overloaded constructor (Parameterized constructor) to set the values of data members of each class. Through Employee class overloaded constructor (Parameterized constructor) all the data members of Employee class should be initialized. Then insert the values of data members of Employee class in a text file “Employee.txt”.  Similarly you should initialize other class data members through their respective overloaded constructor i.e. constructor of LabourCard and HealthCard and insert the data members value in prospective text files and also display on console.
    You have to create text file for each class through code. For example, for employee class you have to make text file named as “Employee.txt” and for LabourCard class you have to make text file named as “LabourCard.txt” and similarly for HealthCard class you have to make text file named as “HealthCard.txt”.


Note:

    Attached with this assignment statement is a file “CS506 Assignment No.1 Demo.gif” which shows sample working output of the assignment.



    Snapshots of the desired solution along with its working are also given in the following pages.

Sample Output:


Before the compilation the directory only contains the following:


After compiling “Employee” class:


Similarly after compiling all the classes:

Now when you run the Driver class, then the following menu will be displayed:


Scenario 1: When user Enter 1:


Then the following information will be displayed:


Similarly a text file named as “Employee.txt” is also created in the directory:

When you open the “Employee” text file, then it will display the provided information:


Scenario 2: When user Enter 2, then:



Similarly it create a text file named as “LabourCard”:


When you open the LabourCard text file, then:



Scenario 3: When user Enter 3, then:



Similarly it creates a text file named as “HealthCard”.


When you open this text file, then it will display the following information:


Scenario 4: When user Enter 4, then:

Note: Your code must justify enough for 20 marks.

Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © virtual university of pakistan - Skyblue - Powered by Blogger - Designed by Johanes Djogan -