The Artima Developer Community
Sponsored Link

Java Answers Forum
Lab3 help

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Bearys M

Posts: 1
Nickname: frenchy
Registered: Nov, 2006

Lab3 help Posted: Nov 8, 2006 11:08 PM
Reply to this message Reply
Advertisement
Hi,
I really need help about my lab3 of how debug the largeTrucksNeeded method and get it to work.I'm using BlueJ to test and run my program and webcat to see what BlueJ could not solve. Below are snippets code of my BigJob classes

public class BigJob
{

/**
* Returns the number of large trucks needed for this job.
* It's necessary to call both largeTrucksNeeded and smallTrucksNeeded to
* determine to total job requirements.
* Returns -1 if there are not enought small or large trucks for job.
*
* @return Number of large trucks needed
*/
public int largeTrucksNeeded()
{
int largeTrucksNeeded =
(int) (Math.floor(concreteAmount) / LARGE_TRUCK_SIZE);

if (largeTrucksNeeded <= largetruckcount)
{

return largeTrucksNeeded;
}
return -1;
}
/**
* Returns the number of small trucks needed for this job.
* It's necessary to call both largeTrucksNeeded and smallTrucksNeeded to
* determine to total job requirements.
* Returns -1 if there are not enought small or large trucks for job.
*
* @return Number of small trucks
*/
public int smallTrucksNeeded()
{
int smallTrucksNeeded = 0;

if (largeTrucksNeeded() >= 0 )
{
double remainderLarge =
concreteAmount - ( LARGE_TRUCK_SIZE
* largeTrucksNeeded());


smallTrucksNeeded =
(int)Math.ceil(remainderLarge / SMALL_TRUCK_SIZE);

}

else
{

smallTrucksNeeded =
(int)Math.ceil(concreteAmount - (largetruckcount *
LARGE_TRUCK_SIZE)) / SMALL_TRUCK_SIZE;

}
if (smallTrucksNeeded <= smalltruckcount)
{
return smallTrucksNeeded;
}
else
{
return -1;
}
}

Test BigJob


/**
* Number of large trucks needed.
*/
public void testLargeTrucksNeeded()
{
BigJob bigJob1 = new BigJob (60.0);
bigJob1.setLargeTruckCount(1);
assertEquals(-1, bigJob1.largeTrucksNeeded());
bigJob1.setLargeTruckCount(5);
assertEquals(4, bigJob1.largeTrucksNeeded());
bigJob1.setConcreteAmt(12.0);
assertEquals(0, bigJob1.largeTrucksNeeded());
}

/**
* Number of small trucks.
*/
public void testSmallTrucksNeeded()
{
BigJob bigJob1 = new BigJob (60.0);
bigJob1.setLargeTruckCount(0);
bigJob1.setSmallTruckCount(2);
assertEquals(-1, bigJob1.smallTrucksNeeded());
bigJob1.setConcreteAmt(21);
bigJob1.setSmallTruckCount(2);
assertEquals(-1, bigJob1.smallTrucksNeeded());
}

My question is what is why webcat take me away point on largetrucksneeded.
Thanks

Topic: Lab3 help Previous Topic   Next Topic Topic: @JoinTable or @JoinColumn

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use