I am trying to write public instance method createParther()
that returns an instance of Couple
. The method does its job by following these rules: one dancer in the couple must be from aList
and the other bList
, one dancer in the couple must be male and the other female. Neither dancer in the couple should be partnered already. If it is not possible to create a couple from amongst the unpartnered dancers, then null
should be returned. If an instance of Couple
is successfully created, both dancers involved in the couple should have their partnered instance variables set to true
. I have attempted to list all the aList
and bList
to together, but then I didn't know to check the requirements as per above. Can anyone demostrate how this could be acheieved? This is not assignment.
public class FoxDancing
{
private List<Couple> coupleList;
private List<Dancer> aList;
private List<Dancer> bList;
public FoxDancing()
{
couplesList = new ArrayList<Parthers>();
aList = new ArrayList<Dancer>();
bList = new ArrayList<Dancer>();
}
public void fieldLists()
{
this.addX("Simon","AList",'m');
this.addX("Jason","AList",'m');
this.addX("Ian","AList",'m');
this.addX("Susan","BList",'f');
this.addX("Helena","BList",'f');
this.addX("Gina","BList",'f');
}
}