Java Object Oriented Write the class files and a sample Dri

Java - Object Oriented

Write the class files and a sample Driver class to test the code:

You are writing code for a child doctor’s office.

Each parent will have:

Last name

First name

Address
ID

number of visits outstanding Balance

an array of Children (aggregation)

Each Child will have:

Name

Sex

A weight

A date of last checkup (String)

A date of last visit (String)

Write the constructor methods and toString ( ) method for each class. Write an equals( ) method for the client based on the client id.

Write a driver that reads in data from a text file to create an array of five Clients.

The driver will print each client’s information (along with the child name and sex)

File structure:

Last name, first name, address, ID, number of visits, balance, number of children

Child name, sex, weight, checkup, last visit data

Solution

1 // Fig. 10.4: Employee.java 2 // Employee abstract superclass. 3 4 public abstract class Employee 5 { 6 private String firstName; 7 private String lastName; 8 private String socialSecurityNumber; 9 10 // three-argument constructor 11 public Employee( String first, String last, String ssn ) 12 { 13 firstName = first; 14 lastName = last; 15 socialSecurityNumber = ssn; 16 } // end three-argument Employee constructor 17 18 // set first name 19 public void setFirstName( String first ) 20 { 21 firstName = first; // should validate 22 } // end method setFirstName 23 24 // return first name 25 public String getFirstName() 26 { 27 return firstName; 28 } // end method getFirstName 29 30 // set last name 31 public void setLastName( String last ) 32 { 33 lastName = last; // should validate 34 } // end method setLastName 35 36 // return last name 37 public String getLastName() 38 { 39 return lastName; 40 } // end method getLastName 41 42 // set social security number 43 public void setSocialSecurityNumber( String ssn ) 44 { 45 socialSecurityNumber = ssn; // should validate 46 } // end method setSocialSecurityNumber 47 48 // return social security number 49 public String getSocialSecurityNumber() 50 { 51 return socialSecurityNumber; 52 } // end method getSocialSecurityNumber 53 54 // return String representation of Employee object 55 @Override 56 public String toString() 57 { 58 return String.format( \"%s %s\ social security number: %s\", 59 getFirstName(), getLastName(), getSocialSecurityNumber() ); 60 } // end method toString 61 62 // abstract method overridden by concrete subclasses 63 public abstract double earnings(); // no implementation here 64 } // end abstract class Employee
Java - Object Oriented Write the class files and a sample Driver class to test the code: You are writing code for a child doctor’s office. Each parent will have

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site