Algorithm-VSM

 view release on metacpan or  search on metacpan

examples/corpus/Interleaved.java  view on Meta::CPAN


import java.util.*;   

////////////////////////////  class Date  ////////////////////////////        

class Date implements Cloneable {
    int month;
    int day;
    int year;
    public Date( int mm, int dd, int yy ) {
        month = mm; day = dd; year = yy;
    }
    public String toString() { 
        return month + " : " + day + " : " + year;
    }
    public Object clone()
    {
        Date date = null;
        try {
            date = ( Date ) super.clone();
        } catch( CloneNotSupportedException e ) {}
        return date;
    }
}


/////////////////////////////  class Cat  /////////////////////////////

class Cat implements Cloneable {
    String name;
    int age;
    public Cat( String nam, int a ) { name = nam ; age = a; }
    public String toString() { return "  Name: " + name 
                                        + "   Age: " + age; }
    public Object clone() {
        Cat cat = null;
        try {
            cat = ( Cat ) super.clone();
        } catch( CloneNotSupportedException e ) {}
        return cat;
    }
}


/////////////////////////////  class Dog  ////////////////////////////

class Dog implements Cloneable {
    String name;
    int age;
    public Dog( String nam, int a ) { name = nam; age = a; }
    public String toString() { return "\nName: " + name 
                                      + "   Age: " + age; }

    public String getName() { return name; }
    public int getAge() { return age; }

    public void print() {
        System.out.println( this );    
    }

    public Object clone() throws CloneNotSupportedException {
        Dog dog = null;
        try {
            dog = ( Dog ) super.clone();
        } catch( CloneNotSupportedException e ) {}
        return dog;
    }
}


//////////////////////////  class Employee  //////////////////////////

class Employee {                 // intentionally left uncloneable

    String firstName, lastName;
    Date dateOfBirth;
    Employee[] friends;
    Auto[] autos;
    Cat kitty;
    Vector dogs;
    Map phoneList;

    public Employee( String first, String last ) {
        firstName = first;  lastName = last;
    }

    public Employee( String first, String last, Date dob ) {
        firstName = first;  lastName = last;
        dateOfBirth = dob == null ? null : (Date) dob.clone();
    }

    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, Vector dogs ) {
        firstName = first;  lastName = last;
        this.dogs = dogs == null ? null : (Vector) 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 );  
    }

    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();



( run in 0.741 second using v1.01-cache-2.11-cpan-56fb94df46f )