diff --git a/.gitignore b/.gitignore index a127f96..7b4d599 100644 --- a/.gitignore +++ b/.gitignore @@ -10,7 +10,5 @@ *.rar hs_err_pid* replay_pid* -**/.metadata/ -**/.classpath **/bin/ .old/ diff --git a/.metadata/.lock b/.metadata/.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.mylyn/.taskListIndex/segments_1 b/.metadata/.mylyn/.taskListIndex/segments_1 new file mode 100644 index 0000000..114d2af Binary files /dev/null and b/.metadata/.mylyn/.taskListIndex/segments_1 differ diff --git a/.metadata/.mylyn/.taskListIndex/write.lock b/.metadata/.mylyn/.taskListIndex/write.lock new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/17/80137ea4d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/17/80137ea4d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..bc358ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/17/80137ea4d59b001f1f5be468e8057a65 @@ -0,0 +1,209 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/1c/e0f99716d69b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/e0f99716d69b001f1f5be468e8057a65 new file mode 100644 index 0000000..ed4f680 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/1c/e0f99716d69b001f1f5be468e8057a65 @@ -0,0 +1,223 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; + + public int totalHumanAge() { return 0; } +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } + + public int totalHumanAge() { + return this.first.totalAge() + this.rest.totalHumanAge(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } + + // Sum of age and pet's age (in human years). + int totalAge() { + return this.age + this.pet.humanAge(); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/c0418853d69b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/c0418853d69b001f1f5be468e8057a65 new file mode 100644 index 0000000..c5d88bf --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/33/c0418853d69b001f1f5be468e8057a65 @@ -0,0 +1,227 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } + + boolean testTotalAge(Tester t) { + return t.checkExpect(horb.totalAge(), 408 + 9); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; + + public int totalHumanAge() { return 0; } +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } + + public int totalHumanAge() { + return this.first.totalAge() + this.rest.totalHumanAge(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } + + // Sum of age and pet's age (in human years). + int totalAge() { + return this.age + this.pet.humanAge(); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/33/f08fc40ad89b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/33/f08fc40ad89b001f1f5be468e8057a65 new file mode 100644 index 0000000..8368765 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/33/f08fc40ad89b001f1f5be468e8057a65 @@ -0,0 +1,228 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } + + boolean testTotalHumanAge(Tester t) { + return t.checkExpect(unpopulated.totalHumanAge(), 0) + && t.checkExpect(onlyHorb.totalHumanAge(), hekOlder.humanAge() + horb.age); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; + + public int totalHumanAge() { return 0; } +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } + + public int totalHumanAge() { + return this.first.totalAge() + this.rest.totalHumanAge(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } + + // Sum of age and pet's age (in human years). + int totalAge() { + return this.age + this.pet.humanAge(); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/3b/7066fe31d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/7066fe31d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..5824a33 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/3b/7066fe31d59b001f1f5be468e8057a65 @@ -0,0 +1,248 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/64/a028da77d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/64/a028da77d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..7a716aa --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/64/a028da77d59b001f1f5be468e8057a65 @@ -0,0 +1,208 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/6f/40b1b77cd49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/6f/40b1b77cd49b001f1f5be468e8057a65 new file mode 100644 index 0000000..1d73a1b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/6f/40b1b77cd49b001f1f5be468e8057a65 @@ -0,0 +1,5 @@ +package delegation; + +public class Main { + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/87/400c2888d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/87/400c2888d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..fd0b0f9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/87/400c2888d59b001f1f5be468e8057a65 @@ -0,0 +1,212 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); + + // Calculate the age in human years. + int humanAge(); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/8f/707b66e6d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/707b66e6d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..2db6527 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/8f/707b66e6d59b001f1f5be468e8057a65 @@ -0,0 +1,218 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; + + public int totalHumanAge() { return 0; } +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } + + public int totalHumanAge() { + return this.first.totalAge() + this.rest.totalHumanAge(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/92/e0c0ef43d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/92/e0c0ef43d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..734838e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/92/e0c0ef43d59b001f1f5be468e8057a65 @@ -0,0 +1,239 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/00c803d1d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/94/00c803d1d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..40c123c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/94/00c803d1d59b001f1f5be468e8057a65 @@ -0,0 +1,212 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/94/40183885d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/94/40183885d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..bc358ee --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/94/40183885d59b001f1f5be468e8057a65 @@ -0,0 +1,209 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/96/504b7b3bd59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/96/504b7b3bd59b001f1f5be468e8057a65 new file mode 100644 index 0000000..f1fba1e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/96/504b7b3bd59b001f1f5be468e8057a65 @@ -0,0 +1,245 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/a6/b0e8ff69079b001f1446f1441f37a845 b/.metadata/.plugins/org.eclipse.core.resources/.history/a6/b0e8ff69079b001f1446f1441f37a845 new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/b4/002fadf3d49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/002fadf3d49b001f1f5be468e8057a65 new file mode 100644 index 0000000..8cf455e --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/b4/002fadf3d49b001f1f5be468e8057a65 @@ -0,0 +1,247 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.hasPet() && this.name.equals(this.pet.getName().unwrap()); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/702a4758079b001f1446f1441f37a845 b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/702a4758079b001f1446f1441f37a845 new file mode 100644 index 0000000..cc4eaa5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/702a4758079b001f1446f1441f37a845 @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/bd/e0a49fe2d49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/e0a49fe2d49b001f1f5be468e8057a65 new file mode 100644 index 0000000..6a9e77b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/bd/e0a49fe2d49b001f1f5be468e8057a65 @@ -0,0 +1,243 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.hasPet() && this.name.equals(this.pet.getName().unwrap()); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c0/70ad954ad49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/70ad954ad49b001f1f5be468e8057a65 new file mode 100644 index 0000000..cc4eaa5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c0/70ad954ad49b001f1f5be468e8057a65 @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c2/403f2215d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/403f2215d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..d23e884 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c2/403f2215d59b001f1f5be468e8057a65 @@ -0,0 +1,248 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.hasPet() && this.name.equals(this.pet.getName().unwrap()); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/c7/500f458b079b001f1446f1441f37a845 b/.metadata/.plugins/org.eclipse.core.resources/.history/c7/500f458b079b001f1446f1441f37a845 new file mode 100644 index 0000000..43728c1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/c7/500f458b079b001f1446f1441f37a845 @@ -0,0 +1,5 @@ +package mastermind; + +public class Main { + +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/cd/d0b04d52d49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/cd/d0b04d52d49b001f1f5be468e8057a65 new file mode 100644 index 0000000..e69de29 diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/d8/109cdfc6d49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/d8/109cdfc6d49b001f1f5be468e8057a65 new file mode 100644 index 0000000..b60f682 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/d8/109cdfc6d49b001f1f5be468e8057a65 @@ -0,0 +1,236 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.hasPet() && this.name.equals(this.pet.getName().unwrap()); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; +} +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/db/a0b93326d89b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/db/a0b93326d89b001f1f5be468e8057a65 new file mode 100644 index 0000000..821c228 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/db/a0b93326d89b001f1f5be468e8057a65 @@ -0,0 +1,228 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } + + boolean testTotalHumanAge(Tester t) { + return t.checkExpect(unpopulated.totalHumanAge(), 0) + && t.checkExpect(onlyHorb.totalHumanAge(), 2457); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); + + // Calculate the total age in human years of all humans and pets. + int totalHumanAge(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; + + public int totalHumanAge() { return 0; } +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } + + public int totalHumanAge() { + return this.first.totalAge() + this.rest.totalHumanAge(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } + + // Sum of age and pet's age (in human years). + int totalAge() { + return this.age + this.pet.humanAge(); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? This would be better implemented as an + // abstract class, but in keeping with the spirit of the assignment, it + // shall reside in the interface. + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/e0/f0970e48d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/e0/f0970e48d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..37c6df1 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/e0/f0970e48d59b001f1f5be468e8057a65 @@ -0,0 +1,215 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/ee/70d00174d59b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/70d00174d59b001f1f5be468e8057a65 new file mode 100644 index 0000000..b9725de --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/ee/70d00174d59b001f1f5be468e8057a65 @@ -0,0 +1,206 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.pet.hasName(s); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.pet.hasName(this.name); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Age of pet in human years. + int humanAge(); + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 6; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public int humanAge() { + return this.age * 7; + } + + public boolean hasName(String name) { + return name.equals(this.name); + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public int humanAge() { return 0; } + public boolean hasName(String name) { return false; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.history/f2/60eb3fd6d49b001f1f5be468e8057a65 b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/60eb3fd6d49b001f1f5be468e8057a65 new file mode 100644 index 0000000..e2f7ead --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.history/f2/60eb3fd6d49b001f1f5be468e8057a65 @@ -0,0 +1,239 @@ +package delegation; + +import tester.Tester; + +class Examples { + IPet foot = new Dog("Foot", 44); + IPet footOlder = new Dog("Foot", 45); + IPet hek = new Cat("Hek", 408); + IPet hekOlder = new Cat("Hek", 409); + IPet unpet = new NoPet(); + IPet stephenDog = new Dog("Stephen", 93); + + Person horb = new Person("Horb", hek, 9); + Person horbOlder = new Person("Horb", hekOlder, 10); + Person minge = new Person("Minge", unpet, 3); + Person mingeOlder = new Person("Minge", unpet, 4); + Person wrist = new Person("Wrist", foot, 60); + Person wristOlder = new Person("Wrist", footOlder, 61); + Person stephenPerson = new Person("Stephen", stephenDog, 88); + + ILoPerson unpopulated = new MtLoPerson(); + ILoPerson onlyHorb = new ConsLoPerson(horb, unpopulated); + ILoPerson mingeAndHorb = new ConsLoPerson(minge, onlyHorb); + ILoPerson mingeAndHorbOneYearLater = + new ConsLoPerson(mingeOlder, + new ConsLoPerson(horbOlder, unpopulated)); + ILoPerson mingeAndStephen = new ConsLoPerson(minge, new ConsLoPerson(stephenPerson, unpopulated)); + + boolean testPetOlder(Tester t) { + return t.checkExpect(foot.older(), footOlder) + && t.checkExpect(hek.older(), hekOlder) + && t.checkExpect(unpet, unpet); + } + + boolean testPersonOlder(Tester t) { + return t.checkExpect(horb.older(), horbOlder) + && t.checkExpect(minge.older(), mingeOlder) + && t.checkExpect(wrist.older(), wristOlder); + } + + boolean testPetGetName(Tester t) { + return t.checkExpect(hek.getName(), new YesString("Hek")) + && t.checkExpect(unpet.getName(), new NoString()) + && t.checkExpect(foot.getName(), new YesString("Foot")); + } + + boolean testPersonSamePetName(Tester t) { + return t.checkExpect(horb.samePetName("Hek"), true) + && t.checkExpect(horb.samePetName("Minkus"), false) + && t.checkExpect(minge.samePetName("8"), false); + } + + boolean testILoPersonOlder(Tester t) { + return t.checkExpect(unpopulated.older(), unpopulated) + && t.checkExpect(mingeAndHorb.older(), mingeAndHorbOneYearLater); + } + + boolean testPetHumanAge(Tester t) { + return t.checkExpect(hek.humanAge(), 2448) + && t.checkExpect(stephenDog.humanAge(), 651) + && t.checkExpect(unpet.humanAge(), 0); + } + + boolean testPersonPetHasSameName(Tester t) { + return t.checkExpect(wrist.petHasSameName(), false) && + t.checkExpect(minge.petHasSameName(), false) && + t.checkExpect(stephenPerson.petHasSameName(), true); + + } + + boolean testAnyNarcissists(Tester t) { + return t.checkExpect(mingeAndHorbOneYearLater.anyNarcissists(), false) && + t.checkExpect(mingeAndStephen.anyNarcissists(), true); + } +} + +// A list of people. +interface ILoPerson { + // Increase each member person's and their pet's ages by one. + ILoPerson older(); + + // Does anyone share a name with their pet? + boolean anyNarcissists(); +} + +class MtLoPerson implements ILoPerson { + public ILoPerson older() { return this; }; + + public boolean anyNarcissists() { return false; }; +} + +class ConsLoPerson implements ILoPerson { + Person first; + ILoPerson rest; + + ConsLoPerson(Person first, ILoPerson rest) { + this.first = first; + this.rest = rest; + } + + public ILoPerson older() { + return new ConsLoPerson(this.first.older(), this.rest.older()); + } + + public boolean anyNarcissists() { + return this.first.petHasSameName() || this.rest.anyNarcissists(); + } +} + +//a pet owner +class Person { + String name; + IPet pet; + int age; // in years + + Person(String name, IPet pet, int age) { + this.name = name; + this.pet = pet; + this.age = age; + } + + // Increase the age of a person and their pet by one year. + Person older() { + return new Person(this.name, this.pet.older(), this.age + 1); + } + + // Do they have a pet (and not an unpet)? + boolean hasPet() { + return this.pet.isPet(); + } + + // Whether a person's pet's name's the same as the given string. + boolean samePetName(String s) { + return this.hasPet() && s.equals(this.pet.getName().unwrap()); + } + + // Return whether they've the same name their pet. + boolean petHasSameName() { + return this.hasPet() && this.name.equals(this.pet.getName().unwrap()); + } +} + +//a pet +interface IPet { + // Increase the age of a pet by one year. + IPet older(); + boolean isPet(); + // Return the name of the pet (maybe). + IMaybeString getName(); + // Age of pet in human years. + int humanAge(); + + // Does the pet have the given name? + boolean hasName(String name); +} + +//a pet cat +class Cat implements IPet { + String name; + int age; // in years + + Cat(String name, int age) { + this.name = name; + this.age = age; + } + + public Cat older() { + return new Cat(this.name, this.age + 1); + } + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 6; +} +} + +//a pet dog +class Dog implements IPet { + String name; + int age; // in years + + Dog(String name, int age) { + this.name = name; + this.age = age; + } + + + public Dog older() { + return new Dog(this.name, this.age + 1); + } + + + public boolean isPet() { return true; } + + public IMaybeString getName() { + return new YesString(this.name); + } + + public int humanAge() { + return this.age * 7; + } +} + +//no pet +class NoPet implements IPet { + public NoPet older() { return this; } + public boolean isPet() { return false; } + public IMaybeString getName() { return new NoString(); } + public int humanAge() { return 0; } +} + +// Maybe a string. +interface IMaybeString { + boolean isString(); + String unwrap(); +} + +// No string. +class NoString implements IMaybeString { + public boolean isString() { return false; } + + // This is an exception and should cause the program to crash, but I don't know how to do that cleanly. + public String unwrap() { int i = 0/0; return "what have you done 😔"; }; +} + +// Yes string. +class YesString implements IMaybeString { + String s; + + YesString(String s) { this.s = s; } + + public boolean isString() { return true; } + public String unwrap() { return this.s; } +} diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location new file mode 100644 index 0000000..5eade1a Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/.org.eclipse.egit.core.cmp/.location differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/af/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/af/history.index new file mode 100644 index 0000000..d6d5532 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/af/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/e4/28/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/e4/28/history.index new file mode 100644 index 0000000..28a9ea5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/e4/28/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..2e70d97 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Tue Nov 05 19:15:56 EST 2024 +.gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..4ab8ee4 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/delegation/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/af/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/af/history.index new file mode 100644 index 0000000..18eb271 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/af/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index new file mode 100644 index 0000000..525e38f Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/e4/4c/history.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index new file mode 100644 index 0000000..1e099f3 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers new file mode 100644 index 0000000..af8bbbe Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/.markers differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties new file mode 100644 index 0000000..2369360 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.egit.core/GitProjectData.properties @@ -0,0 +1,3 @@ +#GitProjectData +#Mon Nov 04 18:48:21 EST 2024 +.gitdir=../.git diff --git a/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat new file mode 100644 index 0000000..293105c Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.projects/mastermind/org.eclipse.jdt.core/state.dat differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version new file mode 100644 index 0000000..25cb955 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index new file mode 100644 index 0000000..ce920a5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version new file mode 100644 index 0000000..6b2aaa7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree b/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree new file mode 100644 index 0000000..1f809c7 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree differ diff --git a/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources new file mode 100644 index 0000000..912be42 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources differ diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs new file mode 100644 index 0000000..67d10c2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/net.sourceforge.vrapper.eclipse.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +vrapperEnabled=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..30841eb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding=UTF-8 +version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs new file mode 100644 index 0000000..a2e2ec3 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.debug.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=\n\n +preferredTargets=default\:default| diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs new file mode 100644 index 0000000..77840f2 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +themeid=org.eclipse.e4.ui.css.theme.e4_dark diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs new file mode 100644 index 0000000..f19f0b9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.workbench.renderers.swt.prefs @@ -0,0 +1,6 @@ +HIDE_ICONS_FOR_VIEW_TABS=false +SHOW_FULL_TEXT_FOR_VIEW_TABS=false +USE_ROUND_TABS=false +eclipse.preferences.version=1 +enableMRU=true +themeEnabled=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs new file mode 100644 index 0000000..8df2034 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.egit.core.prefs @@ -0,0 +1,3 @@ +GitRepositoriesView.GitDirectories=/home/jacob/School/CS3/.git\: +GitRepositoriesView.GitDirectories.relative=.git\: +eclipse.preferences.version=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..357bee6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.classpathVariable.JRE_LIB=/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551/jre/lib/jrt-fs.jar +org.eclipse.jdt.core.classpathVariable.JRE_SRC=/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551/jre/lib/src.zip +org.eclipse.jdt.core.classpathVariable.JRE_SRCROOT= +org.eclipse.jdt.core.classpathVariable.JUNIT_HOME=/app/eclipse/plugins/org.junit_4.13.2.v20230809-1000.jar +org.eclipse.jdt.core.classpathVariable.M2_REPO=/home/jacob/.m2/repository +org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=21 +org.eclipse.jdt.core.compiler.compliance=21 +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=21 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs new file mode 100644 index 0000000..31df02c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.junit.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000..33e9a2f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_VM_XML=\n\n \n \n \n\n diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000..62a4f66 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,91 @@ +content_assist_completion_replacement_background=200,200,0 +content_assist_completion_replacement_foreground=200,0,0 +content_assist_disabled_computers=org.eclipse.jdt.ui.textProposalCategory\u0000org.eclipse.jdt.ui.javaPostfixProposalCategory\u0000org.eclipse.jdt.ui.javaAllProposalCategory\u0000org.eclipse.jdt.ui.javaTypeProposalCategory\u0000org.eclipse.jdt.ui.javaNoTypeProposalCategory\u0000org.eclipse.jdt.ui.javaChainProposalCategory\u0000 +content_assist_lru_history= +content_assist_number_of_computers=15 +content_assist_parameters_background=52,57,61 +content_assist_parameters_foreground=238,238,238 +content_assist_proposals_background=52,57,61 +content_assist_proposals_foreground=238,238,238 +eclipse.preferences.version=1 +java_bracket=249,250,244 +java_comment_task_tag=154,140,124 +java_default=217,232,247 +java_doc_default=128,128,128 +java_doc_keyword=154,140,124 +java_doc_link=169,156,140 +java_doc_tag=30,120,155 +java_keyword=204,108,29 +java_keyword_bold=false +java_keyword_return=204,108,29 +java_keyword_return_bold=false +java_multi_line_comment=128,128,128 +java_operator=230,230,250 +java_single_line_comment=128,128,128 +java_string=23,198,163 +javadocElementsStyling.darkModeDefaultColors=true +matchingBracketsColor=249,250,244 +org.eclipse.jdt.ui.formatterprofiles.version=23 +overriddenByCSS=,content_assist_completion_replacement_background,content_assist_completion_replacement_foreground,content_assist_parameters_background,content_assist_parameters_foreground,content_assist_proposals_background,content_assist_proposals_foreground,java_bracket,java_comment_task_tag,java_default,java_doc_default,java_doc_keyword,java_doc_link,java_doc_tag,java_keyword,java_keyword_bold,java_keyword_return,java_keyword_return_bold,java_multi_line_comment,java_operator,java_single_line_comment,java_string,matchingBracketsColor,pf_coloring_argument,pf_coloring_assignment,pf_coloring_comment,pf_coloring_key,pf_coloring_value,semanticHighlighting.abstractClass.color,semanticHighlighting.abstractClass.enabled,semanticHighlighting.abstractMethodInvocation.color,semanticHighlighting.abstractMethodInvocation.enabled,semanticHighlighting.annotation.color,semanticHighlighting.annotation.enabled,semanticHighlighting.annotation.italic,semanticHighlighting.annotationElementReference.color,semanticHighlighting.annotationElementReference.enabled,semanticHighlighting.class.color,semanticHighlighting.class.enabled,semanticHighlighting.deprecatedMember.color,semanticHighlighting.deprecatedMember.enabled,semanticHighlighting.deprecatedMember.underline,semanticHighlighting.deprecatedMember.strikethrough,semanticHighlighting.enum.color,semanticHighlighting.enum.enabled,semanticHighlighting.enum.italic,semanticHighlighting.field.color,semanticHighlighting.field.enabled,semanticHighlighting.inheritedField.color,semanticHighlighting.inheritedMethodInvocation.color,semanticHighlighting.inheritedMethodInvocation.enabled,semanticHighlighting.interface.color,semanticHighlighting.interface.enabled,semanticHighlighting.localVariable.color,semanticHighlighting.localVariable.enabled,semanticHighlighting.localVariableDeclaration.color,semanticHighlighting.localVariableDeclaration.enabled,semanticHighlighting.localVariableDeclaration.bold,semanticHighlighting.method.color,semanticHighlighting.method.enabled,semanticHighlighting.methodDeclarationName.color,semanticHighlighting.methodDeclarationName.enabled,semanticHighlighting.methodDeclarationName.bold,semanticHighlighting.number.color,semanticHighlighting.number.enabled,semanticHighlighting.parameterVariable.color,semanticHighlighting.parameterVariable.enabled,semanticHighlighting.staticField.color,semanticHighlighting.staticField.enabled,semanticHighlighting.staticFinalField.color,semanticHighlighting.staticFinalField.enabled,semanticHighlighting.staticMethodInvocation.color,semanticHighlighting.staticMethodInvocation.enabled,semanticHighlighting.typeArgument.color,semanticHighlighting.typeArgument.enabled,semanticHighlighting.typeParameter.color,semanticHighlighting.typeParameter.enabled,semanticHighlighting.typeParameter.bold,semanticHighlighting.restrictedKeywords.color,semanticHighlighting.restrictedKeywords.bold,sourceHoverBackgroundColor,javadocElementsStyling.darkModeDefaultColors, +pf_coloring_argument=221,40,103 +pf_coloring_assignment=217,232,247 +pf_coloring_comment=128,128,128 +pf_coloring_key=217,232,247 +pf_coloring_value=23,198,163 +semanticHighlighting.abstractClass.color=62,171,230 +semanticHighlighting.abstractClass.enabled=true +semanticHighlighting.abstractMethodInvocation.color=128,246,167 +semanticHighlighting.abstractMethodInvocation.enabled=true +semanticHighlighting.annotation.color=160,160,160 +semanticHighlighting.annotation.enabled=true +semanticHighlighting.annotation.italic=true +semanticHighlighting.annotationElementReference.color=235,75,100 +semanticHighlighting.annotationElementReference.enabled=true +semanticHighlighting.class.color=18,144,195 +semanticHighlighting.class.enabled=true +semanticHighlighting.deprecatedMember.color=128,128,128 +semanticHighlighting.deprecatedMember.enabled=true +semanticHighlighting.deprecatedMember.strikethrough=true +semanticHighlighting.deprecatedMember.underline=false +semanticHighlighting.enum.color=204,129,186 +semanticHighlighting.enum.enabled=true +semanticHighlighting.enum.italic=true +semanticHighlighting.field.color=102,225,248 +semanticHighlighting.field.enabled=true +semanticHighlighting.inheritedField.color=143,143,191 +semanticHighlighting.inheritedMethodInvocation.color=205,246,104 +semanticHighlighting.inheritedMethodInvocation.enabled=true +semanticHighlighting.interface.color=128,242,246 +semanticHighlighting.interface.enabled=true +semanticHighlighting.localVariable.color=243,236,121 +semanticHighlighting.localVariable.enabled=true +semanticHighlighting.localVariableDeclaration.bold=false +semanticHighlighting.localVariableDeclaration.color=242,242,0 +semanticHighlighting.localVariableDeclaration.enabled=true +semanticHighlighting.method.color=167,236,33 +semanticHighlighting.method.enabled=true +semanticHighlighting.methodDeclarationName.bold=false +semanticHighlighting.methodDeclarationName.color=30,181,64 +semanticHighlighting.methodDeclarationName.enabled=true +semanticHighlighting.number.color=104,151,187 +semanticHighlighting.number.enabled=true +semanticHighlighting.parameterVariable.color=121,171,255 +semanticHighlighting.parameterVariable.enabled=true +semanticHighlighting.restrictedKeywords.bold=false +semanticHighlighting.restrictedKeywords.color=204,108,29 +semanticHighlighting.staticField.color=141,218,248 +semanticHighlighting.staticField.enabled=true +semanticHighlighting.staticFinalField.color=141,218,248 +semanticHighlighting.staticFinalField.enabled=true +semanticHighlighting.staticMethodInvocation.color=150,236,63 +semanticHighlighting.staticMethodInvocation.enabled=true +semanticHighlighting.typeArgument.color=177,102,218 +semanticHighlighting.typeArgument.enabled=true +semanticHighlighting.typeParameter.bold=false +semanticHighlighting.typeParameter.color=191,164,164 +semanticHighlighting.typeParameter.enabled=true +sourceHoverBackgroundColor=68,68,68 +spelling_locale_initialized=true +typefilter_migrated_2=true +useAnnotationsPrefPage=true +useQuickDiffPrefPage=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs new file mode 100644 index 0000000..67b1d96 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.m2e.discovery.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.m2e.discovery.pref.projects= diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs new file mode 100644 index 0000000..43e97e4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +mylyn.attention.migrated=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs new file mode 100644 index 0000000..2a6fe50 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.java.ui.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.java.ui.run.count.3_10_0=1 +org.eclipse.mylyn.java.ui.run.count.3_1_0=1 diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs new file mode 100644 index 0000000..8d462a6 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.monitor.ui.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs new file mode 100644 index 0000000..2b60c21 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.tasks.ui.prefs @@ -0,0 +1,5 @@ +eclipse.preferences.version=1 +migrated.task.repositories.secure.store=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching=true +org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true +org.eclipse.mylyn.tasks.ui.welcome.message=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs new file mode 100644 index 0000000..cec65c4 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.search.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.search.defaultPerspective=org.eclipse.search.defaultPerspective.none diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs new file mode 100644 index 0000000..2e60d5f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +platformState=902606037612457 +quickStart=false +tipsAndTricks=true diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs new file mode 100644 index 0000000..62252c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs @@ -0,0 +1,3 @@ +CURRENT_THEME_ID=org.eclipse.ui.ide.systemDefault +eclipse.preferences.version=1 +showIntro=false diff --git a/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs new file mode 100644 index 0000000..c5ed378 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.workbench.prefs @@ -0,0 +1,67 @@ +//org.eclipse.ui.commands/state/org.eclipse.ui.navigator.resources.nested.changeProjectPresentation/org.eclipse.ui.commands.radioState=false +PLUGINS_NOT_ACTIVATED_ON_STARTUP=;org.eclipse.m2e.discovery; +eclipse.preferences.version=1 +org.eclipse.ui.ide.systemDefault.CONFLICTING_COLOR=240,15,66 +org.eclipse.ui.ide.systemDefault.CONTENT_ASSIST_BACKGROUND_COLOR=52,57,61 +org.eclipse.ui.ide.systemDefault.CONTENT_ASSIST_FOREGROUND_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.EDITION_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.INCOMING_COLOR=31,179,235 +org.eclipse.ui.ide.systemDefault.OUTGOING_COLOR=238,238,238 +org.eclipse.ui.ide.systemDefault.RESOLVED_COLOR=108,210,17 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.CommitMessageCommentColor=128,128,128 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffAddBackgroundColor=11,121,90 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffAddForegroundColor=216,254,245 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHeadlineBackgroundColor=71,71,71 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHeadlineForegroundColor=242,242,242 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHunkBackgroundColor=53,97,113 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffHunkForegroundColor=233,242,254 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffRemoveBackgroundColor=117,2,36 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.DiffRemoveForegroundColor=255,232,237 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.IgnoredResourceBackgroundColor=47,47,47 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.IgnoredResourceForegroundColor=120,120,120 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.UncommittedChangeBackgroundColor=47,47,47 +org.eclipse.ui.ide.systemDefault.org.eclipse.egit.ui.UncommittedChangeForegroundColor=114,157,186 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.inherited=143,143,191 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.match_highlight=206,92,0 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.ColoredLabels.writeaccess_highlight=255,128,128 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.Javadoc.backgroundColor=52,57,61 +org.eclipse.ui.ide.systemDefault.org.eclipse.jdt.ui.Javadoc.foregroundColor=238,238,238 +org.eclipse.ui.ide.systemDefault.org.eclipse.jface.REVISION_NEWEST_COLOR=75,44,3 +org.eclipse.ui.ide.systemDefault.org.eclipse.jface.REVISION_OLDEST_COLOR=154,113,61 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.color.text.quoted=106,133,255 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.category.gradient.end=136,137,133 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.category.gradient.start=85,87,83 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.past.scheduled=52,101,164 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.task.active=117,80,123 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.thisweek.scheduled=85,87,83 +org.eclipse.ui.ide.systemDefault.org.eclipse.mylyn.tasks.ui.colors.foreground.today.scheduled=52,101,164 +org.eclipse.ui.ide.systemDefault.org.eclipse.search.ui.match.highlight=206,92,0 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.editors.rangeIndicatorColor=27,118,153 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=41,41,41 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=43,44,45 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=204,204,204 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=41,41,41 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=43,44,45 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_INNER_KEYLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_OUTER_KEYLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_OUTLINE_COLOR=75,76,79 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=221,221,221 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_UNSELECTED_TABS_COLOR_END=64,64,67 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.ACTIVE_UNSELECTED_TABS_COLOR_START=73,74,77 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_BG_END=49,53,56 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=59,64,66 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_INNER_KEYLINE_COLOR=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_OUTER_KEYLINE_COLOR=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_OUTLINE_COLOR=59,64,66 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_TAB_TEXT_COLOR=187,187,187 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_END=70,70,73 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INACTIVE_UNSELECTED_TABS_COLOR_START=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INFORMATION_BACKGROUND=81,86,88 +org.eclipse.ui.ide.systemDefault.org.eclipse.ui.workbench.INFORMATION_FOREGROUND=238,238,238 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_END=255,255,255 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_BG_START=255,255,255 +org.eclipse.ui.workbench.ACTIVE_NOFOCUS_TAB_TEXT_COLOR=16,16,16 +org.eclipse.ui.workbench.ACTIVE_TAB_BG_END=255,255,255 +org.eclipse.ui.workbench.ACTIVE_TAB_BG_START=255,255,255 +org.eclipse.ui.workbench.ACTIVE_TAB_TEXT_COLOR=46,52,54 +org.eclipse.ui.workbench.INACTIVE_TAB_BG_START=246,245,244 diff --git a/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch b/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch new file mode 100644 index 0000000..237e286 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.core/.launches/cs3.launch @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml new file mode 100644 index 0000000..1b1d4c9 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.ui/dialog_settings.xml @@ -0,0 +1,18 @@ + +
+
+ + + + + + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml new file mode 100644 index 0000000..54ce69d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.debug.ui/launchConfigurationHistory.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi new file mode 100644 index 0000000..b619e3a --- /dev/null +++ b/.metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi @@ -0,0 +1,2505 @@ + + + + activeSchemeId:org.eclipse.ui.defaultAcceleratorConfiguration + + + + + + + + topLevel + shellMaximized + + + + + persp.actionSet:org.eclipse.mylyn.tasks.ui.navigation + persp.actionSet:org.eclipse.ui.cheatsheets.actionSet + persp.actionSet:org.eclipse.search.searchActionSet + persp.actionSet:org.eclipse.text.quicksearch.actionSet + persp.actionSet:org.eclipse.ui.edit.text.actionSet.annotationNavigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.navigation + persp.actionSet:org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo + persp.actionSet:org.eclipse.ui.externaltools.ExternalToolsSet + persp.actionSet:org.eclipse.ui.actionSet.keyBindings + persp.actionSet:org.eclipse.ui.actionSet.openFiles + persp.actionSet:org.eclipse.debug.ui.launchActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaActionSet + persp.actionSet:org.eclipse.jdt.ui.JavaElementCreationActionSet + persp.actionSet:org.eclipse.ui.NavigateActionSet + persp.viewSC:org.eclipse.jdt.ui.PackageExplorer + persp.viewSC:org.eclipse.jdt.ui.TypeHierarchy + persp.viewSC:org.eclipse.jdt.ui.SourceView + persp.viewSC:org.eclipse.jdt.ui.JavadocView + persp.viewSC:org.eclipse.search.ui.views.SearchView + persp.viewSC:org.eclipse.ui.console.ConsoleView + persp.viewSC:org.eclipse.ui.views.ContentOutline + persp.viewSC:org.eclipse.ui.views.ProblemView + persp.viewSC:org.eclipse.ui.views.TaskList + persp.viewSC:org.eclipse.ui.views.ProgressView + persp.viewSC:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.ui.texteditor.TemplatesView + persp.viewSC:org.eclipse.pde.runtime.LogView + persp.newWizSC:org.eclipse.jdt.ui.wizards.JavaProjectWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewPackageCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewClassCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewEnumCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewRecordCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard + persp.newWizSC:org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard + persp.newWizSC:org.eclipse.ui.wizards.new.folder + persp.newWizSC:org.eclipse.ui.wizards.new.file + persp.newWizSC:org.eclipse.ui.editors.wizards.UntitledTextFileWizard + persp.perspSC:org.eclipse.jdt.ui.JavaBrowsingPerspective + persp.perspSC:org.eclipse.debug.ui.DebugPerspective + persp.showIn:org.eclipse.jdt.ui.PackageExplorer + persp.showIn:org.eclipse.team.ui.GenericHistoryView + persp.showIn:org.eclipse.ui.navigator.ProjectExplorer + persp.viewSC:org.eclipse.mylyn.tasks.ui.views.tasks + persp.newWizSC:org.eclipse.mylyn.tasks.ui.wizards.new.repository.task + persp.actionSet:org.eclipse.debug.ui.breakpointActionSet + persp.actionSet:org.eclipse.jdt.debug.ui.JDTDebugActionSet + persp.showIn:org.eclipse.egit.ui.RepositoriesView + persp.newWizSC:org.eclipse.m2e.core.wizards.Maven2ProjectWizard + persp.actionSet:org.eclipse.eclemma.ui.CoverageActionSet + persp.showIn:org.eclipse.eclemma.ui.CoverageView + persp.viewSC:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.showIn:org.eclipse.tm.terminal.view.ui.TerminalsView + persp.viewSC:org.eclipse.jdt.bcoview.views.BytecodeOutlineView + persp.newWizSC:org.eclipse.jdt.junit.wizards.NewTestCaseCreationWizard + persp.actionSet:org.eclipse.jdt.junit.JUnitActionSet + persp.viewSC:org.eclipse.ant.ui.views.AntView + persp.editorOnboardingImageUri:platform:/plugin/org.eclipse.jdt.ui/$nl$/icons/full/onboarding_jperspective.png + persp.editorOnboardingText:Open a file or drop files here to open them. + persp.editorOnboardingCommand:Find Actions$$$Ctrl+3 + persp.editorOnboardingCommand:Show Key Assist$$$Shift+Ctrl+L + persp.editorOnboardingCommand:New$$$Ctrl+N + persp.editorOnboardingCommand:Open Type$$$Shift+Ctrl+T + + + + View + categoryTag:Git + + + + + + + + + View + categoryTag:Mylyn + + + + org.eclipse.e4.primaryNavigationStack + active + noFocus + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Ant + + + + + + org.eclipse.e4.secondaryDataStack + Java + + View + categoryTag:General + + + View + categoryTag:Java + + + View + categoryTag:Java + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:General + + + View + categoryTag:Terminal + + + View + categoryTag:Java + + + + + + + + + View + categoryTag:Help + + + View + categoryTag:General + + + View + categoryTag:Help + + + + + + + View + categoryTag:Help + + + + + + View + categoryTag:General + activeOnClose + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Help + + + + EditorStack + org.eclipse.e4.primaryDataStack + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + + + + removeOnHide + + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + Split Horizontal + + + + Editor + removeOnHide + org.eclipse.jdt.ui.CompilationUnitEditor + Split Horizontal + + + + + + + + + + View + categoryTag:Java + active + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:General + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + + View + categoryTag:Mylyn + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Git + + + + + + View + categoryTag:Terminal + + ViewMenu + menuContribution:menu + + + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Ant + + + + + + View + categoryTag:Java + + ViewMenu + menuContribution:menu + + + + + + toolbarSeparator + + + + Draggable + + + + toolbarSeparator + + + + Draggable + + + + + toolbarSeparator + + + + Draggable + + + Draggable + + + Draggable + + + Draggable + + + toolbarSeparator + + + + Draggable + + + + Draggable + + + toolbarSeparator + + + + toolbarSeparator + + + + Draggable + + + stretch + SHOW_RESTORE_MENU + + + Draggable + HIDEABLE + SHOW_RESTORE_MENU + + + + + stretch + + + Draggable + + + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + TrimStack + Draggable + + + TrimStack + Draggable + + + + + + + + + + + + + + + + + platform:gtk + + + + + + platform:gtk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + platform:gtk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Editor + removeOnHide + + + + + View + categoryTag:Ant + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Gradle + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Debug + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + + + + + View + categoryTag:Git + NoRestore + + + + + View + categoryTag:Git + + + + + View + categoryTag:Help + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Debug + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java Browsing + + + + + View + categoryTag:Java + + + + + View + categoryTag:General + + + + + View + categoryTag:Java + + + + + View + categoryTag:Java + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Language Servers + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Maven + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Mylyn + + + + + View + categoryTag:Oomph + + + + + View + categoryTag:General + + + + + View + categoryTag:Version Control (Team) + + + + + View + categoryTag:Version Control (Team) + + + View + categoryTag:Help + + + + + View + categoryTag:Terminal + + + + + View + categoryTag:Other + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:Help + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + + View + categoryTag:General + + + + glue + move_after:PerspectiveSpacer + SHOW_RESTORE_MENU + + + move_after:Spacer Glue + HIDEABLE + SHOW_RESTORE_MENU + + + glue + move_after:SearchField + SHOW_RESTORE_MENU + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project new file mode 100644 index 0000000..3c10856 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.project @@ -0,0 +1,11 @@ + + + .org.eclipse.egit.core.cmp + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..99f26c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.egit.core/.org.eclipse.egit.core.cmp/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index new file mode 100644 index 0000000..24c03b4 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/1865797976.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index b/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index new file mode 100644 index 0000000..1b993a5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/2954488155.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3024544230.index b/.metadata/.plugins/org.eclipse.jdt.core/3024544230.index new file mode 100644 index 0000000..2d5e1ab Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/3024544230.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index b/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index new file mode 100644 index 0000000..d1bb350 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/3408771930.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index b/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index new file mode 100644 index 0000000..892e9cc Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/3487212494.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/783481251.index b/.metadata/.plugins/org.eclipse.jdt.core/783481251.index new file mode 100644 index 0000000..8132168 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/783481251.index differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache new file mode 100644 index 0000000..593f470 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/assumedExternalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache new file mode 100644 index 0000000..6c79ce8 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalFilesCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps new file mode 100644 index 0000000..c82e850 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/externalLibsTimeStamps differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt b/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt new file mode 100644 index 0000000..5f7d61c --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/indexNamesMap.txt @@ -0,0 +1 @@ +INDEX VERSION 1.134 diff --git a/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt new file mode 100644 index 0000000..8586397 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/javaLikeNames.txt @@ -0,0 +1 @@ +java \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache new file mode 100644 index 0000000..ef308e1 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache differ diff --git a/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt new file mode 100644 index 0000000..ba7a2a5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.core/savedIndexNames.txt @@ -0,0 +1,7 @@ +INDEX VERSION 1.134+/home/jacob/School/CS3/.metadata/.plugins/org.eclipse.jdt.core +3024544230.index +783481251.index +3408771930.index +1865797976.index +3487212494.index +2954488155.index diff --git a/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat new file mode 100644 index 0000000..33e9d99 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat differ diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml new file mode 100644 index 0000000..59948c0 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.launching/.install.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml b/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml new file mode 100644 index 0000000..6dfd7e5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.launching/libraryInfos.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml new file mode 100644 index 0000000..a4ee3cb --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml new file mode 100644 index 0000000..9e390f5 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml @@ -0,0 +1,2 @@ + + diff --git a/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml new file mode 100644 index 0000000..4868a8d --- /dev/null +++ b/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml @@ -0,0 +1,45 @@ + +
+ + + + + +
+ + + + + +
+
+ + + + + +
+
+
+
+ + + + + +
+
+ +
+
+ + +
+
+
+
+
+
+ +
+
diff --git a/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser new file mode 100644 index 0000000..abbf8e5 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.m2e.core/workspaceState.ser differ diff --git a/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml b/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml new file mode 100644 index 0000000..9effde7 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.m2e.logback/logback.2.6.1.20240411-1122.xml @@ -0,0 +1,41 @@ + + + + %date [%thread] %-5level %logger{35} - %msg%n + + + ${org.eclipse.m2e.log.console.threshold:-OFF} + + + + + ${org.eclipse.m2e.log.dir}/0.log + + ${org.eclipse.m2e.log.dir}/%i.log + 1 + 10 + + + 10MB + + + %date [%thread] %-5level %logger{35} - %msg%n + + + + + + WARN + + + + + + + + + + + + + diff --git a/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser b/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser new file mode 100644 index 0000000..1e9a069 Binary files /dev/null and b/.metadata/.plugins/org.eclipse.mylyn.github.ui/avatars.ser differ diff --git a/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup new file mode 100644 index 0000000..1f73e14 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.oomph.setup/workspace.setup @@ -0,0 +1,6 @@ + + diff --git a/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml new file mode 100644 index 0000000..5ca0b77 --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tips.ide/dialog_settings.xml @@ -0,0 +1,3 @@ + +
+
diff --git a/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml new file mode 100644 index 0000000..77b6c9b --- /dev/null +++ b/.metadata/.plugins/org.eclipse.tm.terminal.view.ui/dialog_settings.xml @@ -0,0 +1,11 @@ + +
+
+ +
+
+ +
+
+
+
diff --git a/.metadata/.plugins/org.eclipse.ui.intro/introstate b/.metadata/.plugins/org.eclipse.ui.intro/introstate new file mode 100644 index 0000000..02f134f --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.intro/introstate @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml new file mode 100644 index 0000000..16024ad --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml @@ -0,0 +1,10 @@ + +
+
+ + + + + +
+
diff --git a/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml new file mode 100644 index 0000000..7fccaad --- /dev/null +++ b/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.metadata/version.ini b/.metadata/version.ini new file mode 100644 index 0000000..8a53478 --- /dev/null +++ b/.metadata/version.ini @@ -0,0 +1,3 @@ +#Tue Nov 05 19:46:43 EST 2024 +org.eclipse.core.runtime=2 +org.eclipse.platform=4.33.0.v20240903-0240 diff --git a/delegation/.classpath b/delegation/.classpath new file mode 100644 index 0000000..f9ed317 --- /dev/null +++ b/delegation/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/mastermind/.classpath b/mastermind/.classpath new file mode 100644 index 0000000..f9ed317 --- /dev/null +++ b/mastermind/.classpath @@ -0,0 +1,12 @@ + + + + + + + + + + + +