My software engineering interpretation of this picture

This program would not work:

public Class Husband {

public Husband(string colorIdentifiesAs, string genderIdentifiesAs, string temperament){

this.race = new Race(colorIdentifiesAs);
this.gender = new Gender(genderIdentifiesAs);
this.temperament = new Temperament(temperament);

}

Race race = null;
Gender gender = null;
Temperament temperament = null;

public Items[] GetItems(Stuff stuff){
var itemsToGet = stuff.Items;
for (i = 0, j = itemsToGet.length, i < j; I++) {

var cart = AddToCart(items[i]); var items = Checkout(cart); DriveHome(); CarryAllItemsInOneTrip(); NotifyWife();

if (items.length > 0){
return items;
}
else{
return null;
}
}
}

public Items[] GoToStore(Husband h, Message m){
var hasRandomThing = RunAroundStoreSearchingFor(m.randomThingToCheckFor);
if(hasRandomThing){

return GetItems(6,itemToGet);

}

else{ return null; }

}

}

public Class Wife {

public Wife(string colorIdentifiesAs, string genderIdentifiesAs, string temperament){

this.race = new Race(colorIdentifiesAs);
this.gender = new Gender(genderIdentifiesAs);
this.temperament = new Temperament(temperament);

}

Race race = null;
Gender gender = null;
Temperament temperament = null;

public Message ThinkOfThingsToDemand(string magicWord, string itemReallyWanted, itemDesired, number){

Message m = new Message();
m.itemReallyWanted = itemReallyWanted;
m.randomThingToCheckFor = itemDesired;
m.number = number;
m.text = ‘${magicWord} go to the store and get ${m.itemReallyWanted}. If they have ${m.itemDesired}, get ${m.number}.’

m.randomThingToCheckFor = itemDesired;

return DemandThings(m);

}

public string DemandThings(Message m){
return NotifyHusband(m);
}
}

main{

try{
var husband = new Husband(“white”,”male”, “reasonable”);
var wife = new Wife(“white”,”female”, “demanding”);

while(1){
var message = wife.ThinkOfThingsToDemand(“please”,“milk”,”avocados”,6);
var stuffToGet = wife.DemandThings(message);
husband.GoToStore(stuffToGet);
}
}
catch(error){
console.log(error);
}
}

console:

itemToGet is undefined

Leave a comment