<p>is this right for 1a?</p>
<p>public boolean conflictWith(Appointment other)</p>
<p>boolean doesOverlap=false;
if(this.compareTo(other)==0)
{
doesConflict =true;
return doesConflict;
}
return doesConflict;</p>
<p>is this right for 1a?</p>
<p>public boolean conflictWith(Appointment other)</p>
<p>boolean doesOverlap=false;
if(this.compareTo(other)==0)
{
doesConflict =true;
return doesConflict;
}
return doesConflict;</p>
<p>1A.</p>
<p>public boolean conflictWith(Appointment other)
{
return ((this.getTime()).overlapsWith(other.getTime()));
}</p>
<p>I think mine was simmilar to j567p, but I can't remember for sure. Physicsrocks, maybe I'm missing something but isn't the first return statement repititive since it will return the boolean anyway with the second return. I don't think compareTo would work for what they were asking either.</p>
<p>YES!!!! j567 that's what i put except i didn't use "this"</p>
<p>one thing i didnt like about the test is that when i wrote 1A, they gave us a whole page and i used 4 (2 if you discount brackets) lines. then on the mergesort, i started to run out of space because they gave us the same amount of space.</p>
<p>every class inherits the .equals, and the .compareTo method, so if the two time interval objects were the same the .compareTo should work, and should be zero, so like i dont understand why it wouldn't work?</p>
<p>Every class inherits the equals method which returns true if they're the same object (unless the class overrides it) but only Comparable objects have the compareTo method.</p>
<p>I typed all this out mainly to have my teacher's feedback on it tomorrow but I'd like you guys to see it and tell me what you think, and if all agrees it can be a basis for what we think is right. It's pretty much what I wrote tuesday as well as I can remember.</p>
<p>I wish it showed up neater but here it is:
//1a
public boolean conflictsWith(Appointment other)
{
return getTime().overlapsWith(other.getTime());
}</p>
<p>//1b
public void clearConflicts(Appointment appt)
{
for(int i = 0; i < apptList.size(); i++)
{
if(appt.overlapsWith((Appointment)apptList.get(i)))
{
apptList.remove(i);
i--;
}
}
}</p>
<p>//1c
public boolean addAppt(Appointment appt, boolean emergency)
{
if(emergency)
{
clearConflicts(appt);
apptList.add(appt);
return true;
}</p>
<pre><code>for(int i = 0; i < apptList.size(); i++)
{
if(appt.overlapsWith((Appointment)apptList.get(i)))
return false;
}
apptList.add(appt);
return true;
</code></pre>
<p>}</p>
<p>//2a
public double purchasePrice()
{
return getListPrice() * (1 + taxRate);
}</p>
<p>//2b
public class Vehicle extends TaxableItem
{
private double dealerCost;
private double dealerMarkup;</p>
<pre><code>public Vehicle(double cost, double markup, double rate)
{
super(rate);
dealerCost = cost;
dealerMarkup = markup;
}
public double getListPrice()
{
return dealerCost + dealerMarkup;
}
public void changeMarkup(double markup)
{
dealerMarkup = markup;
}
</code></pre>
<p>}</p>
<p>//3a
public int compareCustomer(Customer other)
{
int nameComparison = getName().compareTo(other.getName());
int IDComparison = getID() - other.getID();</p>
<pre><code>if(nameComparison == 0)
return IDComparison;
return nameComparison;
</code></pre>
<p>}</p>
<p>//3b
public static void prefixMerge(Customer[] list1 etc...)
{
int i = 0;
int j = 0;
int k = 0;</p>
<pre><code>while(i < result.length)
{
if(list1[j].compareCustomer(list2[k]) < 0)
{
result[r] = list1[j];
j++;
}
else if(list1[j].compareCustomer(list2[k]) > 0)
{
result[r] = list2[k];
k++;
}
else if(list1[j].compareCustomer(list2[k]) == 0)
{
result[r] = list1[j];
j++;
k++;
}
r++;
}
</code></pre>
<p>}</p>
<p>//4a
public Location dropLocationForColumn(int column)
{
for(int i = theEnv.numRows() - 1; i >= 0; i--)
if(theEnv.isEmpty(i, column))
return new Location(i, column);</p>
<pre><code>return null;
</code></pre>
<p>}</p>
<p>//4b
public boolean dropMatchesNeighbors(int column, Color pieceColor)
{
Location loc = dropLocationForColumn(column);</p>
<pre><code>ArrayList nbrs = theEnv.getNeighbors(loc);
for(int i = 0; i < nbrs.size(); i++)
if(theEnv.isEmpty((Location)nbrs.get(i)))
{
nbrs.remove(i);
i--;
}
if(nbrs.size() < 3)
return false;
for(int i = 0; i < nbrs.size(); i++)
{
Location nbr = (Location)nbrs.get(i);
Piece p = (Piece)theEnv.objectAt(nbr);
if(!pieceColor.equals(p.color()))
return false;
}
return true;
</code></pre>
<p>}</p>
<p>durrrr. Darn. isEmpty can take rows and columns? I thought it was only (). No wonder it was so hard to me ><; I feel so dumb. I ended up creating a new Location...then realized I couldn't do that but couldn't think so I kept it that way.</p>
<p>And uh, yea I took A. Grr. Want five!</p>
<p>You're right actually, I wrote this up unable to reference the Appendices. I sure hope it's right in my booklet.</p>
<p>A much better look at the solutions: <a href="http://www.skylit.com/beprepared/fr2006.html%5B/url%5D">http://www.skylit.com/beprepared/fr2006.html</a></p>
<p>thanks for the link chipset</p>
<p>thanks a lot!</p>