#Why is this an error?
1 messages · Page 1 of 1 (latest)
Detected code, here are some useful tools:
javapublic static void main(int [] args) {
if (capacity <= 99) {
System.out.println("Island still has capacity");
}
else if (capacity >= 100) {
System.out.println("Island is full");
}
}
}
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
u forgot to share the error
Your right lol
- int should be string
- u never defined what c is
- u never defined what capacity is
- u didn't create a class around this method
what? share the full code of the class please
I have
import java.util.ArrayList;
public class Island
{
// import the ArrayList class
ArrayList<String> PassOB = new ArrayList<String>(); // Create an ArrayList object
private String name;
private int luxuryRating;
private int capacity;
private int passId;
private int islandNO;
public Island(int luxuryRating, int capacity, int passId)
{
luxuryRating = 0;
passId = 0;
capacity = 0;
islandNO = 0;
}
public Island(String n)
{
name = n;
}
public static void main(String[] args){
ArrayList<String> PassOB = new ArrayList<String>();
PassOB.add("Name");
PassOB.add("Luxury Rating");
PassOB.add("Capacity");
PassOB.add("passId");
System.out.println(PassOB);
}
public int GetIslandNo()
{
return islandNO;
}
public int GetRating()
{
return luxuryRating;
}
public int GetCapacity()
{
return capacity;
}
public String GetName()
{
return name;
}
public static void main(int[] args) {
if (capacity <= 99) {
System.out.println("Island still has capacity");
}
else if (capacity >= 100) {
System.out.println("Island is full");
}
}
}```
Detected code, here are some useful tools:
No I meant I have made the class
u already created a main method. why do u want to create another
very odd
when do u want to execute this code? whenever a new island is created?
or when a certain method is called?
or when the program starts?
right now ur new code makes no sense
that's not what i mean
ur describing the code logic itself
but I'm asking for the placement
when should that check be done
whenever a new island is created?
whenever u get the current capacity?
whenever you u change the capacity?
whenever the program starts?
when it ends?
u dont really seem to understand the code ur writing. at least not its flow
like in what order and when which part of ur code is executed
@zinc pewter