This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin Cookbook and have Ken Kousen on-line!
See this thread for details.
Win a copy of Kotlin Cookbook this week in the Kotlin forum!

lilly Potter

Greenhorn
+ Follow
since Nov 29, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by lilly Potter

when I try and compile the following in the interface it says interface methods cannot have body. so how else can i write it?

public boolean isAbleToFly() {
return true;
}
4 days ago


I am writing an interface called Launchable. The Launchable interface specifies three methods: launch(), which takes no argument and returns no value, isAbleToFly(), which takes no argument and returns true or false, and land() which takes no argument and returns no value.

this is what I have attempted for the isAbleToFly
4 days ago


the above is what I have so far. Stuck on the rest. Many thanks

would the rest just be:

return true;
{
else
}
return false;
 
4 days ago
The method should attempt to decrement powerLevel by a random number between 1 and 3 inclusive for each experiment up to numberOfExperiments. You should make use of the supplied helper method randomInteger() for this.

• If the powerLevel can be reduced, a message indicating the experiment number (starting at 1) should be displayed. If not, a suitable message should be displayed and remaining experiments should not be attempted.

• When all experiments have finished it should display "Experiment run stopped


4 days ago

Campbell Ritchie wrote:Frogs don't sit on top of each other round here until the end of February at the earliest.
I presume you have a book to go with your teaching. Doesn't that say how to write a method? If not, try the Java™ Tutorials.
But before you write any more code, write down with pencil and paper what will happen to your xPos and yPos variables if I write something likeShow us what you wrote on your paper. Make sure to get a decent size eraser; you will need it.



done bewlo so far. How do I use the table above to set these for the appropriate increments depending on the supplied argument for direction.

2 weeks ago
So I rece ntly started an apprenticehsip and I am currently learning Java. I have been asked to write a public instance method moveBy() whose first argument is an int representing the distance to move and whose second argument is a char representing the direction in which to move. It should return no value.

Table 1: Directions and corresponding x and y increments

       direction xInc yInc
right  'R'        1 0
left 'L'       -1 0
up 'U'        0 -1
down'D'        0 1

 
Begin by declaring local int variables xInc and yInc and use the table above to set these for the appropriate increments depending on the supplied argument for direction.

      The method should then move the Shape (class) the required distance and direction 1 step at a time, using a loop.

I have only done the method so far.. the argumets are not correct!

2 weeks ago
it should move 2 frogs sat on top of each other together.
2 weeks ago

Carey Brown wrote:I'm assuming that xInc would be a local int variable and would need to be declared. It is not a class variable is it?



yes Its a local int variable and needs to be declared. How would i go about starting this quesiton. I think my method is somewhat correct but not the argument
2 weeks ago
I have only done this so far which doesnt look right!

2 weeks ago
Hi, I havent yet done anything as I am new to do this. But if someone can show me how to start then I will try and do it and post it back here for feedback. Thanks
2 weeks ago
So I rece ntly started an apprenticehsip and I am currently learning Java. I have been asked to write a public instance method moveBy() whose first argument is an int representing the distance to move and whose second argument is a char representing the direction in which to move. It should return no value.

Table 1: Directions and corresponding x and y increments

        direction xInc yInc
right  'R'        1 0
left 'L'       -1 0
up 'U'        0 -1
down'D'        0 1

   
Begin by declaring local int variables xInc and yInc and use the table above to set these for the appropriate increments depending on the supplied argument for direction.

       The method should then move the Shape (class) the required distance and direction 1 step at a time, using a loop.
2 weeks ago
..These methods should be private. So I need to write a method calculateCarpetCost() that takes two int arguments representing the width and length in metres of the carpet to be purchased and returns the cost of the carpet as a double. It should first calculate the area of the carpet than multiply this by the price. But I am struggling with how I should start it off. If anyone can help many thanks, I am up late and have a class to teach tomorrow! the things I do for fun!


I am not sure if that is according to the brief
1 month ago
So I need to write a method calculateCarpetCost() that takes two int arguments representing the width and length in metres of the carpet to be purchased and returns the cost of the carpet as a double. It should first calculate the area of the carpet than multiply this by the price. But I am struggling with how I should start it off. If anyone can help many thanks, I am up late and have a class to teach tomorrow! the things I do for fun!




that looks wrong! if anyone can help many thanks and please no mean comments if you can't help.
1 month ago