#I need help with a Project for class
1 messages ยท Page 4 of 1
alright
ok and so we start out with the max
so we are at the end
while ((line = in.readLine()) != null){
count --;
arr[count] = new Appliance(line);
}```
this part
yes
please post properly formatted code, makes it easier to help
reset it to one
and starts reading the file from the beginning
in = new TextFileInput(filename);```
ye
and while loop
goes to the end
and the count
is subtracted
wait but if we are at the top
isn't it bad if it subtracts
i'm asking to understand
i mean this all works
at the top of what
the file
wait i might be confused
lets say count is at 20
the textinput thingy took me to line 1
and it starts reading and its going down the file
meaning the line increases
yes
I'll post an example
with an array of 3
3 lines
so we have count = 3
for (...) {
count--;
arr[count] = line;
}```
first iteration:
count reduces to 2
arr[2] = line1
second iteration:
count is 1
arr[1] = line 2
third iteration:
count is 0
arr[0] = line 3
that is what is doing
we are reading in reverse yes
we set the array before iterating
sorry while
so it doesn't matter
yes
because we already used it for the array size
and now we can just use
arr.length
we need this counter to iteraite though the line?
the second one i eman
wait but the while
to iterate the array, not the line
does that
ohhh
the line iterates every time it does .readLine()
cause its putting the numbers in the array
yeah
so when the count goes backwards so another number
its putting another line there each time
until it reaches zero
just a bit weird
casue its doing it bakcwards
but it makes sense now
ok cool
i understand this code
here
while ((line = in.readLine()) != null){
count++;
}```
we can delete the line =
because we aren't using the line in the first loop
while (in.readLine() != null)
alright
I think that's all
show
show your code
wrong loop
you're using line in the second loop
so you still need it there
oh right
is it working fine now?
yeah
and crazy thing is i knew it was the first one i was supose tot edit
but i still edited the second ๐
but ye working just fine
I think everything is clear now
Dioxin already explained about inheritance
and the rest you learned in class
yea
everything else i understand
bruh this wifi
at least it bugs out when im done
thanks u so much btw
both of u
not only helped me with the code
but helped me understand
thxs alot
you can close the thread with /help-thread close
bye