Im getting a object not defined exception and I dont know why, I even asked a friend and they couldnt find the issue. | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Im getting a object not defined exception and I dont know why, I even asked a friend and they couldnt find the issue.

https://code.sololearn.com/cQtFXg4Z1tLJ/?ref=app

2nd Oct 2023, 3:00 PM
Asriela Aestas
Asriela Aestas - avatar
5 Réponses
+ 2
I would recommend you to reduce your code to only one class and check the functionality. If that works then you can add a new class and check etc. So you can step by step extend your code and see what make eventually problems.
2nd Oct 2023, 7:19 PM
JaScript
JaScript - avatar
0
Can you US your desired output?
2nd Oct 2023, 4:20 PM
D1M3
D1M3 - avatar
0
It doesnt have an output yet, i just want the code to run without an error.
2nd Oct 2023, 4:35 PM
Asriela Aestas
Asriela Aestas - avatar
0
Try this using System; using System.Collections.Generic; namespace Sololearn { class Program { static void Main(string[] args) { int input = 1; Generate generate = new Generate(input); } } class Generate { enum Group { Friends, Family, Crushes, Enemies } private int userInput; public const int NO_OF_PEOPLE = 5; public const int NO_OF_ROOMS = 4; private List<Person>[] roomsArr = new List<Person>[NO_OF_ROOMS]; private Person[] people = new Person[NO_OF_PEOPLE]; private Random rnd = new Random(); public Generate(int userInput) { this.userInput = userInput; GeneratePeople(); PlacePeople(); // SimulateInteractions(); } private void GeneratePeople() { // Generiere jede Person for (int i = 0; i < NO_OF_PEOPLE; i++)
2nd Oct 2023, 7:36 PM
Siyamend Abde
Siyamend Abde - avatar
0
The problem ended up being that i thought initializing an array of objects actually filled that array with instances of the class.
3rd Oct 2023, 2:07 PM
Asriela Aestas
Asriela Aestas - avatar