Algorithm-VSM
view release on metacpan or search on metacpan
examples/corpus/Manager.java view on Meta::CPAN
public Employee( String first, String last, Date dob, Cat kit ) {
firstName = first; lastName = last;
dateOfBirth = dob == null ? null : (Date) dob.clone();
kitty = kit == null ? null : (Cat) kit.clone();
}
public Employee( String first, String last, ArrayList dogs ) {
firstName = first; lastName = last;
this.dogs = dogs == null ? null : (ArrayList) dogs.clone();
}
Employee( String first, String last, Date dob, Employee[] fnds ) {
firstName = first; lastName = last;
dateOfBirth = dob == null ? null : (Date) dob.clone();
friends = fnds == null ? null : (Employee[]) fnds.clone();
}
Employee( String first, String last, Map phoneList ) {
firstName = first; lastName = last;
this.phoneList = phoneList == null
? null : new TreeMap( (TreeMap) phoneList );
// creates the same mappings
}
Employee( String first, String last, Date dob, Employee[] fnds,
Auto[] ats, Cat c )
{
firstName = first; lastName = last;
dateOfBirth = dob == null ? null : (Date) dob.clone();
friends = fnds == null ? null : (Employee[]) fnds.clone();
autos = ats == null ? null : (Auto[]) ats.clone();
kitty = c == null ? null : (Cat) c.clone();
}
Employee( Employee e ) {
firstName = e.firstName; lastName = e.lastName;
dateOfBirth = e.dateOfBirth == null
? null : (Date) e.dateOfBirth.clone();
friends = e.friends == null
? null : (Employee[]) e.friends.clone();
autos = e.autos == null
? null : (Auto[]) e.autos.clone();
kitty = e.kitty == null
? null : (Cat) e.kitty.clone();
phoneList = e.phoneList == null
? null : new TreeMap( (TreeMap) e.phoneList );
}
public String getFirstName() { return firstName; }
public String getLastName() { return lastName; }
public void addDogToDogs( Dog newDog ) { //(I)
if ( dogs == null ) dogs = new ArrayList();
dogs.add( newDog );
Collections.sort( dogs, new Dog.Dog_Comparator() ); //(J)
}
public String toString() {
String str = "";
if ( dogs != null ) {
str += "\nDOGS: ";
ListIterator iter = dogs.listIterator();
while ( iter.hasNext() )
str += (Dog) iter.next();
str += "\n";
}
if ( autos != null ) {
str += "\nAUTOS: ";
for ( int i=0; i<autos.length - 1; i++ ) {
str += " " + autos[i] + ",";
}
str += " " + autos[autos.length - 1];
str += "\n";
}
if ( friends != null ) {
str += "\nFRIENDS:";
for ( int i=0; i<friends.length; i++ ) {
str += "\n";
str += friends[i].getFirstName();
str += " " + friends[i].getLastName();
}
str += "\n";
}
if ( kitty != null ) {
str += "\nCAT:";
str += kitty;
}
if ( phoneList != null ) {
str += "\nPhone List:";
str += phoneList;
}
return "\nFirst Name: " + firstName + "\nLast Name: "
+ lastName + "\n" + str + "\n";
}
}
//////////////////////////// class Auto /////////////////////////////
class Auto {
String autoBrand;
Employee owner;
public Auto( String brand ) { autoBrand = brand; }
public Auto( String brand, Employee e )
{
autoBrand = brand;
owner = e;
}
public String toString()
{
return autoBrand;
}
}
//////////////////////////// class Poodle ///////////////////////////
class Poodle extends Dog {
private Employee owner;
private double weight; //(K)
private double height;
public Poodle( Employee owner, String name, int age,
double weight, double height )
{
super( name, age );
this.owner = owner;
this.weight = weight;
this.height = height;
}
public Object clone() {
Poodle poo = null;
poo = ( Poodle ) super.clone();
return poo;
}
public String toString() {
return super.toString() + " Pedigree: " + "Poodle "
+ " Weight: " + weight + " Height: " + height ;
}
public double getDogCompareParameter(){ return weight; } //(L)
}
( run in 1.119 second using v1.01-cache-2.11-cpan-39bf76dae61 )