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 trialJoshua Salas
732 PointsA little confused what the questions is asking for. Can someone help me with the code
N/a
class GoKart {
public static final int MAX_BARS = 8;
private String color;
public GoKart(String color) {
this.color = color;
}
public void fill(){
private barCount=MAX_BARS;
}
public String getColor() {
return color;
}
}
1 Answer
Evans Owino
24,888 PointsHi,
Step one is asking you to declare a private field barCount that will be used to track the number of energy bars. As we are tracking the quantity of something, we should use the data type int, so:
private int barCount
Step two is asking you to create a method called charge that sets the new barCount field to the maximum amount. As the specification doesn't specify that we need to return a value, let's make the return type of the method as void, so:
public void charge() {
this.barCount = MAX_BARS;
}
Hope this helps.