C#
C#

help

Root Question Message

Enigma
Enigma12/24/2022
❔ help with creating a list of objects from other lists

yo, i have a project on nodes (a list of lists) and on the the functions i need to create a new party (the second tier) of all the character (first tier) which have the highest level in each party, how would i get around doing this, i have some code but its currently not working, this is the code, i would love some help, thank you public void SpecMinMax() //10
{
Node<Party> temp = Partylist;
Party minmax = new Party("minmax");
while (temp != null)
{
minmax.AddChar(temp.GetValue().FindStrongestChar());
temp = temp.GetNext();
}
temp = new Node<Party>(minmax, temp);
}
cathei
cathei12/24/2022
$code
cathei
cathei12/24/2022
What is Node here, are you doing linked list not List<T>?
Enigma
Enigma12/24/2022
i belive node is a linked list, with value and next, i just work on an alternate version of that with my school
Enigma
Enigma12/24/2022
'''cs
Enigma
Enigma12/24/2022
// public void SpecMinMax() //10
{
Node<Party> temp = Partylist;
Party minmax = new Party("minmax");
while (temp != null)
{
minmax.AddChar(temp.GetValue().FindStrongestChar());
temp = temp.GetNext();
}
temp = new Node<Party>(minmax, temp);
}
Enigma
Enigma12/24/2022
'''
cathei
cathei12/24/2022
It should be backtick ` not ‘
Enigma
Enigma12/24/2022
//        public void SpecMinMax() //10
        {
            Node<Party> temp = Partylist;
            Party minmax = new Party("minmax");
            while (temp != null)
            {
                minmax.AddChar(temp.GetValue().FindStrongestChar());
                temp = temp.GetNext();
            }
            temp = new Node<Party>(minmax, temp);
        }
 
Enigma
Enigma12/24/2022
the goal of the action is to create a new party minmax
Enigma
Enigma12/24/2022
which concludes of the strongest character from each party
Enigma
Enigma12/24/2022
if u need any clarity with the code lmk
cathei
cathei12/24/2022
Yay. and what is “not working” here
cathei
cathei12/24/2022
Shouldn’t you update PartyList?
Enigma
Enigma12/24/2022
Partylist is simply the list off all parties
Enigma
Enigma12/24/2022
class World
{
private string name;
private Node<Party> Partylist;
Enigma
Enigma12/24/2022
this are the properties of world
cathei
cathei12/24/2022
By the while condition the temp is always null after loop
Enigma
Enigma12/24/2022
the party is just not created
Enigma
Enigma12/24/2022
are u here?
cathei
cathei12/24/2022
Like I said you should add node to PartyList
cathei
cathei12/24/2022
Either head or tail
Enigma
Enigma12/24/2022
wdym node
Enigma
Enigma12/24/2022
node is the type of thing
Enigma
Enigma12/24/2022
Node<party> is a list of parties
cathei
cathei12/24/2022
So you should add your newly created party node
Enigma
Enigma12/24/2022
like Partylist = Partylist(Partylist,minmax)
Enigma
Enigma12/24/2022
or something of the following
cathei
cathei12/24/2022
Basically, but make sure you don’t lose your link to another node
Enigma
Enigma12/24/2022
thanks
Enigma
Enigma12/24/2022
i changed my code to this
Enigma
Enigma12/24/2022
public void SpecMinMax() //10
{
Node<Party> temp = Partylist;
Party minmax = new Party("minmax");
while (temp != null)
{
minmax.AddChar(temp.GetValue().FindStrongestChar());
temp = temp.GetNext();
}
temp = new Node<Party>(minmax, temp);
Partylist = temp;
Enigma
Enigma12/24/2022
and now once i use the action it only keeps the minmax party
cathei
cathei12/25/2022
Because temp is null after while loop
Enigma
Enigma12/25/2022
I see
Enigma
Enigma12/25/2022
So i dont really get what should i change
cathei
cathei12/25/2022
Partylist = new Node<Party>(minmax, Partylist);

Try this instead
Enigma
Enigma12/25/2022
Thanks
ContactFrequently Asked QuestionsJoin The DiscordBugs & Feature RequestsTerms & Privacy