- Thanks for the tip, will be putting them in when I finish the assignment.
-Gotcha
-Not sure what you mean by this, but will definitely keep this in mind
-Got the Copy constructor to work, and so far the program runs pretty nicely but I'm now on my final step.
- Will be posting one on this post
-About the Vectors, you're totally right. A friend in my class used vectors and it worked nicely but I decided not to because I would need to change some stuff inside my Heap/PQ implementations.
---------Outputs--------
Printer queue
=========
1. Add job
2. Print job
3. View jobs
4. Exit
Enter choice: 3
No print jobs in queue.
[menu output]
Enter choice: 2
No print jobs in queue.
[menu output]
Enter choice: 1
Instructor (I or i), TA (T or t), or Student (S or s)? s
[menu output]
Enter choice: 3
job #1: Student
[menu output]
Enter choice: 1
Instructor (I or i), TA (T or t), or Student (S or s)? i
[menu output]
Enter choice: 3
job #2: Instructor
job #1: Student
[menu output]
Enter choice: 1
Instructor (I or i), TA (T or t), or Student (S or s)? t
[menu output]
Enter choice: 3
job #2: Instructor
job #3: TA
job #1: Student
[menu output]
Enter choice: 1
Instructor (I or i), TA (T or t), or Student (S or s)? i
[menu output]
Enter choice: 3
job #2: Instructor
job #4: Instructor
job #3: TA
job #1: Student
[menu output]
Enter choice: 2
Now printing job #2: Instructor
---------------End--------------------------
My issue now is outputting the Job "#" . I noticed the Job "#" is simply the location in the Array where the Job is stored inside. So I decided to make another struct and made two integers. So the best place I could think of to keep track of the Length is inside enqueue but then I ran into a problem.
1 2 3 4 5 6
|
struct Job
{
int position; // position in the array.
int jobNum; // Job number
};
|
1 2 3 4 5 6 7
|
void PQType<ItemType>::Enqueue(ItemType newItem)
{
length++;
//I want to pass the value of Length onto "position" inside my struct.
items.elements[length - 1] = newItem;
items.ReheapUp(0, length - 1);
}
|
this was my first attempt but it didn't work, was this a proper way?
1 2 3 4 5 6 7 8
|
void PQType<ItemType>::Enqueue(ItemType newItem)
{
// Job j;
length++;
// j.position = length;
items.elements[length - 1] = newItem;
items.ReheapUp(0, length - 1);
}
|
sadly, it kept outputting garbage.