Algorithm-VSM
view release on metacpan or search on metacpan
examples/corpus/Interleaved.java view on Meta::CPAN
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();
kitty = c == null ? null : (Cat) c.clone();
}
String getFirstName() { return firstName; }
String getLastName() { return lastName; }
public String toString() {
String str = "";
if ( dogs != null ) {
str += "\nDOGS: ";
for ( int i=0; i<dogs.size(); i++ ) {
str += (Dog) dogs.elementAt(i);
}
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 TestEmployee ////////////////////////
class TestEmployee {
public static void main( String[] args )
{
Employee e1 = new Employee( "Zoe", "Zaphod" );
Employee e2 = new Employee ( "YoYo", "Ma",
new Date( 2, 12, 2000 ) );
Employee[] empList = new Employee[2];
empList[0] = e1;
empList[1] = e2;
Auto[] autoList = new Auto[2];
Auto a1 = new Auto( "Chevrolet" );
Auto a2 = new Auto( "Ford" );
autoList[0] = a1;
autoList[1] = a2;
Cat purr = new Cat( "socks", 5 );
( run in 1.105 second using v1.01-cache-2.11-cpan-39bf76dae61 )