Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Help! Class problem.

$
0
0
Hey guys, im trying to create a priority queue in C#. In my case i gonna need a queue of vector3, soo i start creating a class called Charge with have a vector3 and a double for priority, then i create the class PriorityQueue that is a list of charge. You can follow the code below: public class Charge{ public Vector3 vetor = new Vector3(); public double priority = new double (); public Charge(Vector3 a, double b){ vetor = a; priority = b; } } public class PriorityQueue where Charge : new (){ private List elements = new List(); Charge t ; public int Count { get { return elements.Count; } } public void Enqueue(Vector3 item, double priority) { t = new Charge(item, priority); elements.Add(t); } public Charge Dequeue() { int bestIndex = 0; Charge bestItem = new Charge(); for (int i = 0; i < elements.Count; i++) { if (elements[i].priority < elements[bestIndex].priority) { bestIndex = i; } } bestItem = elements[bestIndex].vetor; elements.RemoveAt(bestIndex); return bestItem; } } However i geting 3 errors: error CS0417: `Charge': cannot provide arguments when creating an instance of a variable type error CS1061: Type `Charge' does not contain a definition for `priority' and no extension method `priority' of type `Charge' could be found. error CS1061: Type `Charge' does not contain a definition for `vetor' and no extension method `vetor' of type `Charge' could be found. The thing is i don't get it, why i can't access the methods of the class i just created? did i made something wrong? can someone explain me plis. Thx

Viewing all articles
Browse latest Browse all 2891

Trending Articles