#I need help with a Project for class

1 messages ยท Page 4 of 1

left tartan
#

so we can read from the begining again

#

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

uncut marsh
#

yes

left tartan
#

lets say the size was 20

#

that textfile before it

deep ravine
left tartan
#

reset it to one

uncut marsh
left tartan
#
in = new TextFileInput(filename);```
#

ye

#

and while loop

#

goes to the end

#

and the count

#

is subtracted

uncut marsh
#

we are filling the array from arr[19] to arr[0]

left tartan
#

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

uncut marsh
left tartan
#

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

uncut marsh
#

and the counter decreases

#

you're confused by that right?

left tartan
#

yes

uncut marsh
#

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

left tartan
#

up and down and up and down

#

ok

#

i think what i was thinking was

uncut marsh
left tartan
#

i thought it would mess with the size of the array

#

but that previous if

uncut marsh
#

we set the array before iterating

left tartan
#

sorry while

uncut marsh
#

so it doesn't matter

left tartan
#

takes care of that

#

so now we can do whatever we want with the counter

uncut marsh
#

yes

#

because we already used it for the array size

#

and now we can just use

#

arr.length

left tartan
#

we need this counter to iteraite though the line?

#

the second one i eman

#

wait but the while

uncut marsh
left tartan
#

does that

left tartan
uncut marsh
#

the line iterates every time it does .readLine()

left tartan
#

cause its putting the numbers in the array

uncut marsh
left tartan
#

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

uncut marsh
#

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)

left tartan
#

alright

uncut marsh
#

I think that's all

left tartan
#

its showing red ๐Ÿ’€

#

i'm not touching it

#

๐Ÿ˜ญ

uncut marsh
left tartan
#

not red

#

but it wont run

uncut marsh
#

show your code

left tartan
uncut marsh
#

you're using line in the second loop

#

so you still need it there

left tartan
#

oh right

uncut marsh
#

is it working fine now?

left tartan
#

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

uncut marsh
#

I think everything is clear now

#

Dioxin already explained about inheritance

#

and the rest you learned in class

left tartan
#

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

uncut marsh
#

you can close the thread with /help-thread close

left tartan
#

alright

#

cya

uncut marsh
#

bye