#Need Help with a project for class

1 messages · Page 1 of 1 (latest)

fluid ibex
#

I'm a beginner when it comes to java and I'm lost on how to do my project

ember moatBOT
#

<@&987246399047479336> please have a look, thanks.

fluid ibex
#

I'm working on 9 files for this so this is what i have in them

#
public class Project2 {
    
    public static void main(String args[]) {
        
        
    }

}```
#
public class ApplianceGUI {

}```
ember moatBOT
fluid ibex
#
abstract public class Appliance {
    protected int price;
    
    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
ember moatBOT
fluid ibex
#
public class Refrigerator extends Appliance {
    private int feet;
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
ember moatBOT
fluid ibex
#
public class Microwave extends Appliance {
    private int watts;
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
ember moatBOT
fluid ibex
#
public class Dishwasher extends Appliance{
    private boolean uci;
    
    
    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

}
ember moatBOT
fluid ibex
#
public class ApplianceNode {
    
    protected Appliance data;
    protected ApplianceNode next;
    
    public ApplianceNode(Appliance d) {
        data = d;
        next = null;
    }
    

}```
ember moatBOT
fluid ibex
#
public abstract class ApplianceList {
    protected ApplianceNode first;
    protected ApplianceNode last;
    protected int length;
    
    public ApplianceList() {
        ApplianceNode dummy= new ApplianceNode(null);
        first = dummy;
        last = dummy;
        length = 0;
    }
    
    public void append(Appliance a) {
        ApplianceNode x = new ApplianceNode(a);
        last.next = x;
        last = x;
        length++;
            
    }

}```
ember moatBOT
fluid ibex
#
public class SortedApplianceList extends ApplianceList {
    public SortedApplianceList() {
        super();
    }
    
    public void add(Appliance a) {
        ApplianceNode p = first;
        
        if (first == last) {
            append(a);
        }
        
        while (p != null) {
            
            if (p.next == null) {
                append(a);
                break;
            }
            
            if(p.next.data.compareTo(a)>= 0) {
                ApplianceNode y = new ApplianceNode(a);
                y.next = p.next;
                p.next = y;
                length++;
                break;
            }
            
            
            
            p = p.next;
        
        }
    
        
    }

}````
ember moatBOT
finite anchor
#

What's your specific question?

fluid ibex
#

I need help with it step by step because there is alot I don't understand

finite anchor
#

But what specifically are you stuck on?

fluid ibex
#

so I guess starting with the applainces

#

i'm stuck on the appliances rn

#

my refeg, dishwah, and micro

finite anchor
#

But what about of Appliances are you stuck on.

fluid ibex
#

all extend my applaince class

#

well for one the appliances

#
public class Refrigerator extends Appliance {
    private int feet;
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
#

i'm not sure how to write it

#

or how to use the tostring method here

#

i put price in my applance class

#

since it was supose to be in all the other 3 applainces

#

but as for the tostring method, i know we overrride it for the use of each appliance

#

but idk what to do with it

#
abstract public class Appliance {
    protected int price;
    
    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
finite anchor
#

So each appliance has a toString which should return something else.

fluid ibex
#

yes

#

i guess return that certain type of appliance

finite anchor
#

And your assignment just states what's unique per appliance type.

fluid ibex
#

yea

#

i guess the first letter

#

i should probably mention this project is built off our first one

#

but in that one, we only had two files

#

like this was how it was written

ember moatBOT
fluid ibex
#

and this was the appliance class

#
public class Appliance {

    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
#

but with this project, we're using lists and nodes and inheriterence

#

maybe it doesn't help saying that but i thought i'd mention it

#

but yeah starting with the appliances in this project, since each has to return its own type of appliance back

finite anchor
#

Please do try to ask specific questions. Because I am honestly a bit puzzled what your specific issue is.

#

You keep stating appliances, without stating what the issue is.

fluid ibex
#

i'm not sure how to go about it

#

Alright, I need help with how to make it return an appliance for each type of appliance

#

what i mean is

#
public class Refrigerator extends Appliance {
    private int feet;
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
#
public class Microwave extends Appliance {
    private int watts;
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
#
public class Dishwasher extends Appliance{
    private boolean uci;
    
    
    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
#

these all extend my appliance class

#

i'm trying to figure out how to make it return that string of an applaince back

finite anchor
#

You just call the toString on appliance. It's generic, so the one of the actual type will be called.

fluid ibex
#

u say its generic, so that means my code doesn't know which appliance its talking about right?

#

maybe i need constuctors

#

but my appliance class has them

finite anchor
#

Appliance fridge = new Refridgerator();

#

When you then call toString on fridge the Refridgerator toString is used.

fluid ibex
#
public class Refrigerator extends Appliance {
    private int feet;

public Refrigerator(int f){
feet = f;
}
    
    @Override
    
    public String toString() { // just returns the serial number
Appliance fridge = new Refrigerator();
        return fridge;
    }

}```
#

it probably doesn't go in the method but i need to understand

#

so i wanna ask things

#

so since refeg extended to appliance

#

it means i can decalre refeg the same way i can declare an applaince?

finite anchor
#

Refridgerator should have a constructor which accepts feet.

#

Or call a setter.

#

As it stands you never get it.

#

Also a toString should not construct a new object.

#

It should just return a textual representation.

fluid ibex
#

alright but where would declaring the appliance go if no in the method or constuctor

finite anchor
#

Wherever you need it. Most likely where you start processing the file.

#

I recommend checking out:

fluid ibex
#

oh our main method

ember moatBOT
#

MOOC is a completely free introductory Java course created by the University of Helsinki, it is a great way to learn Java from the ground up.

  • The MOOC teaches a broad introduction to programming in Java in two parts - one at beginner, and another at intermediate level.
    The end of the course is marked by creating your own Asteroids game clone!
  • The MOOC allows using features up to Java 11 - you can install Temurin OpenJDK 11 from the Adoptium project.
  • To submit exercises for evaluation, you need to configure an Editor/IDE (Integrated Development Environment) with the TMC Plugin.

The course instructions will suggest to use TMCBeans/NetBeans or VS Code for the course, but you can also use IntelliJ.

  • TMCBeans/NetBeans is the easiest to configure - but has the most dated user experience
  • VS Code is very popular as an editor, but it is quite new for Java Development. Some extra configuration is needed.
  • IntelliJ arguably has the best user experience and is most widely used Java IDE by professionals.
    IntelliJ requires installing a version no newer than 2023.1 - because the IntelliJ TMC Plugin doesn't work with newer installs.
    The IntelliJ Community version is free and all you need to install the TMC plugin.

This server currently recommends IntelliJ.

To use IntelliJ with the MOOC, simply install the TMC plugin by opening IntelliJ -> File -> Settings -> Plugins and searching for TMC. You will then be able to use IntelliJ to complete MOOC.

Visit MOOC here: https://java-programming.mooc.fi/
(the course is available in both English and Finnish)

About the course - Java Programming

fluid ibex
#

right i guess it woukdn't make sense to create the datatype of the refergrertor within it's class

fluid ibex
#

Also apologies but I have to go rn but I'll be back in a couple of hours

finite anchor
#

No problem.

ember moatBOT
#

@fluid ibex

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

fluid ibex
#

Ok I'm back

fluid ibex
#

I think I'm confused

#

my subclasses wouldn't need to have the tostring method if it's already in the appliance class right?

#
abstract public class Appliance {
    protected double price;
    
    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
#
public class Refrigerator extends Appliance {
    private int feet;

    public Refrigerator(String SRN){
        super(SRN);
    }
    
    @Override
    
    public String toString(SRN) { // just returns the serial number
        return SRN;
    }

}```
#
public class Microwave extends Appliance {
    
    private int watts;
    
    public Microwave(String SRN) {
        super(SRN);
    }
    
    @Override
    
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
#
public class Dishwasher extends Appliance{
    private boolean uci;
    
    
    public Dishwasher(String SRN) {
        super(SRN);
    }
    
    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

}```
fluid ibex
#

so do i just make the tostrign method in appliance abstract

#

or well this is how i have rn

#
abstract public class Appliance {
    
    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
#
public class Refrigerator extends Appliance {
    private int feet;
    private double price;

    public Refrigerator(String SRN, double p,int f){
        super(SRN);
        feet = f;
        price = p;
    }
    
    @Override

    public String toString() { // just returns the serial number
        return "Refrigerator - Serial Number: " + getSRN();
    }

}```
#
public class Microwave extends Appliance {
    
    private int watts;
    private double price;
    
    public Microwave(String SRN, double p,int w) {
        super(SRN);
        watts=w;
        price =p;
    }
    
    @Override
    
    public String toString() {
        return "Microwave - Serial Number: " + getSRN();
    }

}```
#
public class Dishwasher extends Appliance{
    private boolean underCountInstall;
    private double price;
    
    
    public Dishwasher(String SRN,double p, boolean uci ) {
        super(SRN);
        price =p;
        underCountInstall = uci;
    }
    
    @Override
    public String toString() {
        return "Dishwasher - Serial Number: " + getSRN();
    }

}```
#

also why does it tell me my getSRN is undefined when i extended to appliance

ember moatBOT
#

@fluid ibex

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍

unborn path
#

@fluid ibex ping me in a few hours, i'll loop back. doing work

fluid ibex
#

hey sorry I was caught up with work for alot longer than i hoped

#

i wanted to say i got my code to work

#

but i still wanted to help to understand everything

#

I'll just post the code here but rn I just want explnations to what some parts of the code is doing

#
public class Project2 {

    public static void main(String args[]) {
        ApplianceGUI allAppliance = new ApplianceGUI();
        allAppliance.readfile();
        allAppliance.DisplayGUI();

    }
}```
#

abstract public class Appliance {

    private String SRN;

    public Appliance (String SRN) {
        this.SRN = SRN;
    }

    @Override
    public String toString() { // just returns the serial number
        return SRN;
    }

    public int compareTo (Appliance x) {
        return this.SRN.compareTo(x.SRN);
    }

    @Override
    public boolean equals(Object other){   
        return other != null && getClass() == other.getClass() && SRN.equals(((Appliance) other).SRN);  // check if two serial numbers equal each other
    }

    public char convert(){   // takes in a serial number and returns the first letter 
        if ((SRN.isEmpty())) return 'X';
        return SRN.charAt(0);
    }

    public String getSRN() {
        return SRN;
    }

    public void setSRN(String SRN) {
        this.SRN = SRN;
    }
}```
#
public class Refrigerator extends Appliance {
    private int feet;
    private double price;

    public Refrigerator(String SRN, double p,int f){
        super(SRN);
        feet = f;
        price = p;
    }

    @Override

    public String toString() { // just returns the serial number
        return "Refrigerator - Serial Number: " + getSRN();
    }

}```
#
public class Microwave extends Appliance {

    private int watts;
    private double price;

    public Microwave(String SRN, double p,int w) {
        super(SRN);
        watts=w;
        price =p;
    }

    @Override

    public String toString() {
        return "Microwave - Serial Number: " + getSRN();
    }

}```
#
public class Dishwasher extends Appliance{
    private boolean underCountInstall;
    private double price;


    public Dishwasher(String SRN,double p, boolean uci ) {
        super(SRN);
        price =p;
        underCountInstall = uci;
    }

    @Override
    public String toString() {
        return "Dishwasher - Serial Number: " + getSRN();
    }

}```
#
public class ApplianceNode {

    protected Appliance data;
    protected ApplianceNode next;

    public ApplianceNode(Appliance d) {
        data = d;
        next = null;
    }
}```
#
public abstract class ApplianceList {
    protected ApplianceNode first;
    protected ApplianceNode last;
    protected int length;

    public ApplianceList() {
        ApplianceNode dummy= new ApplianceNode(null);
        first = dummy;
        last = dummy;
        length = 0;
    }

    public void append(Appliance a) {
        ApplianceNode x = new ApplianceNode(a);
        last.next = x;
        last = x;
        length++;

    }

}```
#
public class SortedApplianceList extends ApplianceList {
    public SortedApplianceList() {
        super();
    }

    public void add(Appliance a) {
        ApplianceNode p = first;

        if (first == last) {
            append(a);
        }

        while (p != null) {

            if (p.next == null) {
                append(a);
                break;
            }

            if(p.next.data.compareTo(a)>= 0) {
                ApplianceNode y = new ApplianceNode(a);
                y.next = p.next;
                p.next = y;
                length++;
                break;
            }



            p = p.next;

        }


    }

}```
#

this was the file we had to read from

R45839RHJ783,2195,22
R389502JNM32,972,16
R2847786SFLK,1599,20
M1189SSK9023,295,50
M8579UKH9RI3,49,10
M7389FIE9283,99,25
D78WJH7662DJ,589,Y
D44NDMDOE758,399,N
D82974IOUFDB,1280,Y
R37859KDIUW7,1285,17
R378OEJF7834,1366,15
M349FJKEI374,299,30
D234NDJF8372,458,Y
M8934KFD8394,129,12
M4589EFKEJ34,159,14
R349FJKE9383,875,12
D73I9ER83742,952,Y
D28994KFH893,457,N
R38DH39462KE,2399,25
R34RE837563I,456,10
#

and finally this is what it prints

#

now for my questions

fluid ibex
fluid ibex
# fluid ibex

for this code,

public void FillGUI() {
        Container myContentPane = getContentPane(); 
        TextArea refeg = new TextArea();  
        TextArea dishWash = new TextArea(); 
        TextArea micro = new TextArea();  
        setLayout(new GridLayout(1,3));

        ApplianceNode curr = rList.first.next;
        while(curr !=null) {
            refeg.append(curr.data.toString() + "\n");
            curr=curr.next;
        }

        ApplianceNode curr2 = dList.first.next;

        while(curr2 !=null) {
            dishWash.append(curr2.data.toString()+ "\n");
            curr2=curr2.next;
        }
        ApplianceNode curr3 = mList.first.next;
        while(curr3 !=null) {
            micro.append(curr3.data.toString() + "\n");
            curr3=curr3.next;
        }

        refeg.setEditable(false);  
        dishWash.setEditable(false);  
        micro.setEditable(false); 

        myContentPane.add(refeg);
        myContentPane.add(dishWash);
        myContentPane.add(micro);
    }```

could you explain what exactly ```ApplianceNode curr = rList.first.next;``` is saying?
unborn path
#

waking up

unborn path
# fluid ibex for my sortedApplianceList, could u explain what's fully going on in the add met...
public class SortedApplianceList extends ApplianceList {
    public SortedApplianceList() {
        super();
    }

    public void add(Appliance a) {
        ApplianceNode p = first;

        if (first == last) {
            append(a);
        }

        while (p != null) {

            if (p.next == null) {
                append(a);
                break;
            }

            if(p.next.data.compareTo(a)>= 0) {
                ApplianceNode y = new ApplianceNode(a);
                y.next = p.next;
                p.next = y;
                length++;
                break;
            }



            p = p.next;

        }


    }

}
#

okay so I think that if (first == last) is a ghetto "is empty" check

#

then the next part is an insertion sort

#

just puts the element in the right place in the list

#

but didn't you write this code?

#

what exactly am i explaining?

fluid ibex
fluid ibex
fluid ibex
#

I just wanted an explanation on what they did to make sure I got it fully

unborn path
#

because

#

stop

fluid ibex
unborn path
#

okay

#

thats better

fluid ibex
#

I don’t use ai to do code

unborn path
fluid ibex
#

But to explain things to me sometimes

unborn path
#

so long as the item isn't already in the list

#
        while (p != null) {

            if (p.next == null) {
                append(a);
                break;
            }

            if(p.next.data.compareTo(a)>= 0) {
                ApplianceNode y = new ApplianceNode(a);
                y.next = p.next;
                p.next = y;
                length++;
                break;
            }



            p = p.next;

        }
fluid ibex
#

But it would defeat the purpose of me learning if I did that 😭

unborn path
#

correct, good job

#

but okay

#

the way this works is - if we reach the end of this linked list we append

#

we only reach the end if we didn't find a place to put it before the end

#

so going left to right

#

lets say we have this list

#
4 -> 7 -> 9 -> 22
#

and we want to insert 8

#

so we start here

#
V
4 -> 7 -> 9 -> 22
#
if(p.next.data.compareTo(a)>= 0) {
#

so the next is 7

#

is 7 greater than or equal to 8? no

#

so next

#
     V
4 -> 7 -> 9 -> 22
#

the next one is 9

#

so is 9 greater than or equal to 8? yes

#

so this is where we splict in 8

#
4 -> 7 -> 8 -> 9 -> 22
#

now lets insert 9999

#

it will make it all the way to the end

#
                     V
4 -> 7 -> 8 -> 9 -> 22 -> null
#

and this is where it hits this branch

#
            if (p.next == null) {
                append(a);
                break;
            }
#

and thats when we append

#

when there is no place before the end to add the thing

fluid ibex
#

Ohh

#

Alright that makes sense

#

Ok basically u have empty

#

And then u have the end

fluid ibex
#

Like what exactly it’s doing

finite anchor
#

What do you think it does?

fluid ibex
#

Going through the linked list

#

But there is a lot of dots

#

Actually it’s the while u would use to go through each of list until the end

finite anchor
#

Do you know the difference between: foo.bla and foo.bla()?

fluid ibex
#

But I know once u do, u add in the info u collected from reading onto that specific appliance list

#

If foo.bla is a built in function then no

#

But if it’s about the parenthesis

finite anchor
#

What is foo?

fluid ibex
#

No idea

finite anchor
#

Ok, what is your rList?

fluid ibex
#

Haven’t ever heard of foo

finite anchor
#

Don't think too far.

fluid ibex
#

Yes that’s what’s it’s declared as

finite anchor
#

You're thinking too far.

#

Is it a variable, a method, ... ?

fluid ibex
#

It’s a linked list

finite anchor
#

That wasn't the question.

fluid ibex
#

Hm

#

A variable then

finite anchor
#

Why do you think that?

#

Or rather, how can you tell?

fluid ibex
#

rList is the variable that stores a linked list data type I made

finite anchor
#

That's not the question.

fluid ibex
#

I don’t know what u mean, I’ve declared it that way

#

So that’s why I think it is

finite anchor
#

My question is literally:

foo; <= variable or method
bar(); <= variable or method

Because the reason you don't get what's going on is seemingly you not noticing/knowing/recognizing what they respectively are.

fluid ibex
#

Oh I see

#

Second one is method

#

Cause parenthesis

#

First one would be a vairbke

#

Every method has parenthesis

#

That was the question then

finite anchor
#

So what would rList.first indicate?

fluid ibex
#

Its a pointer maybe

finite anchor
#

What?

fluid ibex
#

Nvm

#

rList I think is a vairbke

#

And the . Thing

#

That would be a method?

finite anchor
#

Yes, and do you know how to call the methods of a variable, or access it's accessible variables?

fluid ibex
#

Usually it’s with .dot

#

Like

#

rList.append

finite anchor
#

Ok. so first has no parenthesis, so what is it? Variable or method?

fluid ibex
#

I only think it’s a method cause of the dot

#

But it doesn’t have parenthesis

#

So it could just be a vairbke

finite anchor
#

No, a dot just indicates you're acting upon what's to the left of the dot.

fluid ibex
#

Okay so it would be good to ask

#

What does rList.first indicate

#

Cause I’m seeing that I don’t know

finite anchor
#

I am trying to figure out where/why you're stuck.

#

You know rList is a variable, and you know its type.

#

You know . indicates we're using something of the variable/class to the left of it.

fluid ibex
#

I think I was confused with nodes

#

Cause I recently learned it

#

But first is the first node

finite anchor
#

In this case the specific type doesn't even matter.

fluid ibex
#

Does that mean it’s the first thing in the linked list

finite anchor
#

It's just .first vs .first(). Both could indicate a note. In the former case as a variable, the second case a method.

#

Well second since they also use .next.

fluid ibex
#

oh alright

#

okay so rList.first

#

means it's looking at the first node?

#

and then .next

finite anchor
#

Yes.

fluid ibex
#

the one after?

finite anchor
#

It gets the next element of the first node.

#

Or rather, it gets the next element of the node it's called upon. Which in this case is the first node.

fluid ibex
#

so the first calls the next node then

#

u know what

#

lemme draw this out

#

i need visual represenation

#

Ok so currently that’s what just that line is doing right

fluid ibex
#

Okay

#

This is what I think is happening

#

So there is a node called curr and I’m saying that inside the list, it’ll be pointed to the first node which points the next node

#

And the while loop is gonna go through the entire list until it’s very last which is null

#

And throughout that process, each time, it’s gonna print the current serial number in the list in the textarea

#

And once it’s printed that current one, the next current node will be the node after that in the rList

#

That’s what I think is happening

#

I’m sure something is wrong with that but that’s what I think is going on

ember moatBOT
#

@fluid ibex

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍