Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Joushva Kamble
855 PointsHaving trouble with lab involving java
package part3;
public class Mal { private String _quote0; private String _quote1; private String _quote2; private String _quote3;
public Mal() {
_quote0 = "I aim to misbehave."; // https://en.wikiquote.org/wiki/Serenity_(film)
_quote1 = "I don't believe there is a power in the verse that can stop Kaylee from being cheerful."; // http://firefly.wikia.com/wiki/Quotes
_quote2 = "Jayne, your mouth is talking. You might wanna look to that."; //http://firefly.wikia.com/wiki/Quotes
_quote3 = " Well, we may not have parted on the best of terms. I realize certain words were exchanged. Also, certain... bullets.";
}
public String getQuote() {
rotateQuotes();
return "Mal: " + _quote3;
}
public void rotateQuotes() {
String temp = _quote3;
_quote3 = _quote2;
_quote2 = _quote1;
_quote1 = temp;
}
}
I need to debug this code so that i can get this as the output:
Calling getQuote() the first time on a Mal object should produce: Mal: I aim to misbehave. What I got was: Mal: Jayne, your mouth is talking. You might wanna look to that. Calling getQuote() the second time on a Mal object should produce: Mal: I don't believe there is a power in the verse that can stop Kaylee from being cheerful. What I got was: Mal: I don't believe there is a power in the verse that can stop Kaylee from being cheerful. Calling getQuote() the third time on a Mal object should produce: Mal: Jayne, your mouth is talking. You might wanna look to that. What I got was: Mal: Well, we may not have parted on the best of terms. I realize certain words were exchanged. Also, certain... bullets. Calling getQuote() the fourth time on a Mal object should produce: Mal: Well, we may not have parted on the best of terms. I realize certain words were exchanged. Also, certain... bullets. What I got was: Mal: Jayne, your mouth is talking. You might wanna look to that. Calling getQuote() the fifth time on a Mal object should produce: Mal: I aim to misbehave. What I got was: Mal: I don't believe there is a power in the verse that can stop Kaylee from being cheerful.
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsAlexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsWell, I've no idea what the task is.
Could you explain what to do?
What bug do we need to fix?
What problem we have to solve?
Code runs fine. The output is the same, when we uncomment
checkZoeSecondQuote();:What output should be?