Need help for loop
I need help i want to make a program that makes people infected and the infected people infect others and so on
55 Replies
so if have 1 infected that one infects another one and is now 2 and now those 2 infect 2 others and is now 4 and so on
pastemyst | (untitled)
a powerful website for storing and sharing text and code snippets. completely free and open source.
my code
pastemyst | (untitled)
a powerful website for storing and sharing text and code snippets. completely free and open source.
pastemyst | (untitled)
a powerful website for storing and sharing text and code snippets. completely free and open source.
the classes
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
when run the for statements
all people get infected
and i dont want that
i want 2 people to get infected
because one from the original
and one new
and then i want those 2 to infect 4 others
but somehow all people is infected
any clues?
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
doesnt matter
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
pastemyst | (untitled)
a powerful website for storing and sharing text and code snippets. completely free and open source.
this is where i infect others
put it in another class
pastemyst | (untitled)
a powerful website for storing and sharing text and code snippets. completely free and open source.
and row 50
im using it
but that isnt the way im supposed to use it cause everyone gets infected
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
yeah but after one gets infected i want it to double
so lets say
1 is infected
he infects another one
now its 2 infector
and those 2 infector infects 2 more
now its 4 infector
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
PERFECTTT
THANKSSSSSSS
â¤ď¸
int toContamine = persons.Count(x => x.Infected) * 2;
never seen that line before
and deleted the *2
and it worked as i wanted đ
so the code was int toContamine = persons.Count(x => x.Infected)
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
ahhhhh
thanksss
â¤ď¸
is x a int
?
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
ah thanks â¤ď¸
hey sorry @zonedetec to bother but is it possible to get the info on how many people is infected?
Console.WriteLine(persons.Count(x => x.Infected) + " is infected");
ive done this
but it shows incorrect at 19
it is supposed to show 18
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
thinking because of this
if (Smittade >= 20)
{
Smittade = 20;
}
it resets to 20
and then it takes -1 from there
in my other class
but if i dont include that when it goes above 20 it crashes
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
when i come to 15 it is correct and then it turns into 19 instead of 18
no i dont want it to crash
:S
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
made some changes to the code
want me to send the new one ?
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
hahahahahaa aight
where can i do that ?
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
the first is just for display
can remove that
wanted to see
the maths behind it
you can remove it if you wanna
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
how ? đŽ
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
yup
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
still same at 6 hours, it still 19 infected and if you count it, its 18
20 people
-2
18
and at 7 hours it displays 17 infected when it should be 16
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
no at 6 it should be 18
since 2 people get unsick
OH MB
HAHAHAH
MB
B
MB
wait
it was 21 people
mb
so it was correct
lmfao
so 21-2
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
is 19
hahahahaha
mb
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
sorry đł
thank youuu
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
really appreciate your help man â¤ď¸
nope ? :/
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
yeah
Unknown Userâ˘3y ago
Message Not Public
Sign In & Join Server To View
Adding to what csharp co-founder said, have a look at this
First look at the debugger - Visual Studio (Windows)
Get started debugging applications using the Visual Studio debugger
đŽ
thanksss really appreciate the tips and help â¤ď¸