Fixed .gitignore for the last time.
This commit is contained in:
Binary file not shown.
@@ -1,209 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,223 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,227 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,228 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,248 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,208 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
package delegation;
|
||||
|
||||
public class Main {
|
||||
|
||||
}
|
@@ -1,212 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,218 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,239 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,212 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,209 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,245 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,247 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
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
|
@@ -1,243 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,7 +0,0 @@
|
||||
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
|
@@ -1,248 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
package mastermind;
|
||||
|
||||
public class Main {
|
||||
|
||||
}
|
@@ -1,236 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,228 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,215 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,206 +0,0 @@
|
||||
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; }
|
||||
}
|
@@ -1,239 +0,0 @@
|
||||
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; }
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
#GitProjectData
|
||||
#Tue Nov 05 19:15:56 EST 2024
|
||||
.gitdir=../.git
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,3 +0,0 @@
|
||||
#GitProjectData
|
||||
#Mon Nov 04 18:48:21 EST 2024
|
||||
.gitdir=../.git
|
Binary file not shown.
@@ -1 +0,0 @@
|
||||
|
Binary file not shown.
@@ -1 +0,0 @@
|
||||
|
Binary file not shown.
Binary file not shown.
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
vrapperEnabled=true
|
@@ -1,3 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding=UTF-8
|
||||
version=1
|
@@ -1,3 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<launchPerspectives/>\n
|
||||
preferredTargets=default\:default|
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
themeid=org.eclipse.e4.ui.css.theme.e4_dark
|
@@ -1,6 +0,0 @@
|
||||
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
|
@@ -1,3 +0,0 @@
|
||||
GitRepositoriesView.GitDirectories=/home/jacob/School/CS3/.git\:
|
||||
GitRepositoriesView.GitDirectories.relative=.git\:
|
||||
eclipse.preferences.version=1
|
@@ -1,11 +0,0 @@
|
||||
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
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.launching.PREF_VM_XML=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\n<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1730764015248" defaultVMConnector\="">\n <vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\n <vm id\="1730764015248" name\="jre" path\="/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551/jre"/>\n </vmType>\n</vmSettings>\n
|
@@ -1,91 +0,0 @@
|
||||
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=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><history maxLHS\="100" maxRHS\="10"/>
|
||||
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
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.m2e.discovery.pref.projects=
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
mylyn.attention.migrated=true
|
@@ -1,3 +0,0 @@
|
||||
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
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true
|
@@ -1,5 +0,0 @@
|
||||
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
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.search.defaultPerspective=org.eclipse.search.defaultPerspective.none
|
@@ -1,4 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
platformState=902606037612457
|
||||
quickStart=false
|
||||
tipsAndTricks=true
|
@@ -1,3 +0,0 @@
|
||||
CURRENT_THEME_ID=org.eclipse.ui.ide.systemDefault
|
||||
eclipse.preferences.version=1
|
||||
showIntro=false
|
@@ -1,67 +0,0 @@
|
||||
//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
|
@@ -1,21 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
|
||||
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/delegation"/>
|
||||
</listAttribute>
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
|
||||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<mapAttribute key="org.eclipse.debug.core.environmentVariables">
|
||||
<mapEntry key="DISPLAY" value=":0"/>
|
||||
</mapAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="tester.Main"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="mastermind"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="${project_name}.Examples"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="delegation"/>
|
||||
</launchConfiguration>
|
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="org.eclipse.debug.ui.LAUNCH_CONFIGURATIONS_DIALOG_SECTION">
|
||||
<item key="org.eclipse.debug.ui.DIALOG_SASH_WEIGHTS_1" value="237"/>
|
||||
<item key="org.eclipse.debug.ui.DIALOG_SASH_WEIGHTS_2" value="762"/>
|
||||
<item key="org.eclipse.debug.ui.EXPANDED_NODES" value=", org.eclipse.jdt.launching.localJavaApplication, "/>
|
||||
<item key="DIALOG_WIDTH" value="1089"/>
|
||||
<item key="DIALOG_HEIGHT" value="1072"/>
|
||||
<item key="DIALOG_FONT_NAME" value="1|Cantarell|11.0|0|GTK|1|"/>
|
||||
</section>
|
||||
<section name="org.eclipse.debug.ui.STRING_VARIABLE_SELECTION_DIALOG_SECTION">
|
||||
<item key="DIALOG_X_ORIGIN" value="0"/>
|
||||
<item key="DIALOG_Y_ORIGIN" value="0"/>
|
||||
<item key="DIALOG_WIDTH" value="444"/>
|
||||
<item key="DIALOG_HEIGHT" value="701"/>
|
||||
<item key="DIALOG_FONT_NAME" value="1|Cantarell|11.0|0|GTK|1|"/>
|
||||
</section>
|
||||
</section>
|
@@ -1,29 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchHistory>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.debug">
|
||||
<mruHistory>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="cs3"/> "/>
|
||||
</mruHistory>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.profile">
|
||||
<mruHistory/>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.eclemma.ui.launchGroup.coverage">
|
||||
<mruHistory>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="cs3"/> "/>
|
||||
</mruHistory>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.ui.externaltools.launchGroup">
|
||||
<mruHistory/>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
<launchGroup id="org.eclipse.debug.ui.launchGroup.run">
|
||||
<mruHistory>
|
||||
<launch memento="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <launchConfiguration local="true" path="cs3"/> "/>
|
||||
</mruHistory>
|
||||
<favorites/>
|
||||
</launchGroup>
|
||||
</launchHistory>
|
File diff suppressed because it is too large
Load Diff
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>.org.eclipse.egit.core.cmp</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
INDEX VERSION 1.134
|
@@ -1 +0,0 @@
|
||||
java
|
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
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
|
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<dirs>
|
||||
<entry loc="/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551/jre" stamp="0"/>
|
||||
<entry loc="/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551" stamp="0"/>
|
||||
</dirs>
|
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<libraryInfos>
|
||||
<libraryInfo home="/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551/jre" version="21.0.4"/>
|
||||
<libraryInfo home="/app/eclipse/plugins/org.eclipse.justj.openjdk.hotspot.jre.full.linux.x86_64_21.0.4.v20240802-1551" version="21.0.4">
|
||||
<bootpath>
|
||||
<entry path="null"/>
|
||||
</bootpath>
|
||||
<extensionDirs>
|
||||
<entry path="null"/>
|
||||
</extensionDirs>
|
||||
<endorsedDirs>
|
||||
<entry path="null"/>
|
||||
</endorsedDirs>
|
||||
</libraryInfo>
|
||||
</libraryInfos>
|
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<typeInfoHistroy/>
|
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<qualifiedTypeNameHistroy/>
|
@@ -1,45 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<item key="org.eclipse.jdt.ui.last.selected.jre.kind2" value="2"/>
|
||||
<item key="org.eclipse.jdt.ui.last.selected.execution.enviroment" value="JavaSE-21"/>
|
||||
<item key="org.eclipse.jdt.ui.last.selected.create.moduleinfo.comments" value="false"/>
|
||||
<item key="org.eclipse.jdt.ui.last.selected.create.moduleinfo" value="false"/>
|
||||
<item key="org.eclipse.jdt.ui.lastextjar" value="/home/jacob/School/CS3/libs"/>
|
||||
<section name="org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart">
|
||||
<item key="group_libraries" value="true"/>
|
||||
<item key="layout" value="2"/>
|
||||
<item key="rootMode" value="1"/>
|
||||
<item key="linkWithEditor" value="false"/>
|
||||
<item key="memento" value="<?xml version="1.0" encoding="UTF-8"?>
<packageExplorer group_libraries="1" layout="2" linkWithEditor="0" rootMode="1" workingSetName="Aggregate for window 1730763422386">
<customFilters userDefinedPatternsEnabled="false">
<xmlDefinedFilters>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.StaticsFilter" isEnabled="false"/>
<child filterId="org.eclipse.buildship.ui.packageexplorer.filter.gradle.buildfolder" isEnabled="true"/>
<child filterId="org.eclipse.mylyn.java.ui.MembersFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonJavaProjectsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer_patternFilterId_.*" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonSharedProjectsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.SyntheticMembersFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ContainedLibraryFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.HideInnerClassFilesFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.EmptyInnerPackageFilter" isEnabled="true"/>
<child filterId="org.eclipse.m2e.MavenModuleFilter" isEnabled="false"/>
<child filterId="org.eclipse.buildship.ui.packageexplorer.filter.gradle.subProject" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ClosedProjectsFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.DeprecatedMembersFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.EmptyLibraryContainerFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.PackageDeclarationFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.ImportDeclarationFilter" isEnabled="true"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonJavaElementFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.LibraryFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.CuAndClassFileFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.internal.ui.PackageExplorer.EmptyPackageFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.NonPublicFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.LocalTypesFilter" isEnabled="false"/>
<child filterId="org.eclipse.jdt.ui.PackageExplorer.FieldsFilter" isEnabled="false"/>
</xmlDefinedFilters>
</customFilters>
</packageExplorer>"/>
|
||||
</section>
|
||||
<section name="JavaProjectWizard.dialogBounds">
|
||||
<item key="DIALOG_X_ORIGIN" value="20"/>
|
||||
<item key="DIALOG_Y_ORIGIN" value="20"/>
|
||||
<item key="DIALOG_WIDTH" value="815"/>
|
||||
<item key="DIALOG_HEIGHT" value="930"/>
|
||||
<item key="DIALOG_FONT_NAME" value="1|Cantarell|11.0|0|GTK|1|"/>
|
||||
</section>
|
||||
<section name="JavaElementSearchActions">
|
||||
</section>
|
||||
<section name="NewClassCreationWizard.dialogBounds">
|
||||
<item key="DIALOG_X_ORIGIN" value="20"/>
|
||||
<item key="DIALOG_Y_ORIGIN" value="20"/>
|
||||
<item key="DIALOG_WIDTH" value="664"/>
|
||||
<item key="DIALOG_HEIGHT" value="754"/>
|
||||
<item key="DIALOG_FONT_NAME" value="1|Cantarell|11.0|0|GTK|1|"/>
|
||||
</section>
|
||||
<section name="OptionalMessageDialog.hide.">
|
||||
<item key="org.eclipse.jdt.ui.typecomment.deprecated" value="true"/>
|
||||
</section>
|
||||
<section name="NewClassWizardPage">
|
||||
<item key="create_constructor" value="false"/>
|
||||
<item key="create_unimplemented" value="true"/>
|
||||
</section>
|
||||
<section name="completion_proposal_size">
|
||||
</section>
|
||||
<section name="quick_assist_proposal_size">
|
||||
</section>
|
||||
<section name="BuildPathsPropertyPage">
|
||||
<item key="pageIndex" value="2"/>
|
||||
</section>
|
||||
</section>
|
Binary file not shown.
@@ -1,41 +0,0 @@
|
||||
<configuration scan="true">
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>${org.eclipse.m2e.log.console.threshold:-OFF}</level> <!-- change to DEBUG to mimic '-consolelog' behaviour -->
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${org.eclipse.m2e.log.dir}/0.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
|
||||
<FileNamePattern>${org.eclipse.m2e.log.dir}/%i.log</FileNamePattern>
|
||||
<MinIndex>1</MinIndex>
|
||||
<MaxIndex>10</MaxIndex>
|
||||
</rollingPolicy>
|
||||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
|
||||
<MaxFileSize>10MB</MaxFileSize>
|
||||
</triggeringPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%date [%thread] %-5level %logger{35} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<appender name="EclipseLog" class="org.eclipse.m2e.logback.appender.EclipseLogAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>WARN</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="MavenConsoleLog" class="org.eclipse.m2e.logback.appender.MavenConsoleAppender">
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
<appender-ref ref="STDOUT" />
|
||||
<appender-ref ref="EclipseLog" />
|
||||
<appender-ref ref="MavenConsoleLog" />
|
||||
</root>
|
||||
</configuration>
|
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<setup:Workspace
|
||||
xmi:version="2.0"
|
||||
xmlns:xmi="http://www.omg.org/XMI"
|
||||
xmlns:setup="http://www.eclipse.org/oomph/setup/1.0"
|
||||
name="workspace"/>
|
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
</section>
|
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="LaunchTerminalSettingsDialog">
|
||||
<item key="terminalLabel" value="Local Terminal"/>
|
||||
<section name="SettingsPanelControl">
|
||||
<section name="Local Terminal">
|
||||
<item key="encoding" value="UTF-8"/>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
||||
</section>
|
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<state reopen="false"/>
|
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<section name="Workbench">
|
||||
<section name="WorkbenchPreferenceDialog.dialogBounds">
|
||||
<item key="DIALOG_X_ORIGIN" value="0"/>
|
||||
<item key="DIALOG_Y_ORIGIN" value="0"/>
|
||||
<item key="DIALOG_WIDTH" value="829"/>
|
||||
<item key="DIALOG_HEIGHT" value="804"/>
|
||||
<item key="DIALOG_FONT_NAME" value="1|Cantarell|11.0|0|GTK|1|"/>
|
||||
</section>
|
||||
</section>
|
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<workingSetManager>
|
||||
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1730763421824_0" label="Java Main Sources" name="Java Main Sources"/>
|
||||
<workingSet editPageId="org.eclipse.jdt.internal.ui.DynamicSourcesWorkingSet" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1730763421837_1" label="Java Test Sources" name="Java Test Sources"/>
|
||||
<workingSet aggregate="true" factoryID="org.eclipse.ui.internal.WorkingSetFactory" id="1730763422386_2" label="Window Working Set" name="Aggregate for window 1730763422386"/>
|
||||
</workingSetManager>
|
@@ -1,3 +0,0 @@
|
||||
#Tue Nov 05 19:46:43 EST 2024
|
||||
org.eclipse.core.runtime=2
|
||||
org.eclipse.platform=4.33.0.v20240903-0240
|
Reference in New Issue
Block a user