Question
[C++] The program works but not in the way I want it to. I am trying to get my program output to look like the
[C++] The program works but not in the way I want it to. I am trying to get my program output to look like the picture I posted. In my program, the menu keeps repeating 3x and I don't know how I can add family member separately while at the same time, give them toDo tasks later on...
[Queue.cpp]
#ifndef QUEUE_H_INCLUDED #define QUEUE_H_INCLUDED
using namespace std;
class Queue{
private: struct Node { char *name; Node* next; }; public: Node *front, *rear; Queue(); ~Queue(); void enqueue(char*); void dequeue(char*); void display(); char name[10]; char menu(); };
#endif // QUEUE_H_INCLUDED
[Queue.cpp]
#include "Queue.h" #include "Item.h" #include
using namespace std;
Queue::Queue(){ front = NULL; rear = NULL; }
Queue::~Queue(){ while(front!=NULL){ Node *temp=front; front=front->next; delete temp; } rear = NULL; }
void Queue::enqueue(char *n){ Node* temp= new Node; if (temp == NULL){ cout name = n; temp->next = NULL; /* if (cin >> '3'){ Item itemA; itemA.getTask(); itemA.getDesc(); itemA.setTask(itemA.taskName); itemA.setDesc(itemA.taskDesc); itemA.addNode(itemA.taskName,itemA.taskDesc); } */ if (front== NULL){ front = rear; rear = temp; } else { rear-> next = temp; rear = temp; } cout
void Queue::dequeue(char *d){ if (front == NULL){ cout namenext; } }
void Queue::display(){ if(front ==NULL){ cout name next; Item itemB; itemB.printList(); } cout
char Queue::menu(){ char choice; cout
cin >> choice; return choice; }
[Item.h] #ifndef ITEM_H_INCLUDED #define ITEM_H_INCLUDED class Item{ private: struct node{ char taskName[10]; char taskDesc[80]; node* next; }; node* head; node* curr; node* temp; public: Item(); void addNode(char addTask[],char addDesc[]); void deleteNode(char deleteTask[],char deleteDesc[]); void printList(); void getTask(); void getDesc(); void setTask(char text[]); void setDesc(char text[]); char taskName[10]; char taskDesc[80]; }; #endif // ITEM_H_INCLUDED [Item.cpp] #include "Item.h" #include [main.cpp] #include int main() { char choice; do { Queue A; Item B; choice = A.menu(); switch(choice){ case '1': A.enqueue(A.name); break; case '2': A.display(); break; case '3': B.addNode(B.taskName,B.taskDesc); break; case '4': B.deleteNode(B.taskName,B.taskDesc); break; default: cout /* Item itemA; itemA.getTask(); itemA.getDesc(); itemA.setTask(itemA.taskName); itemA.setDesc(itemA.taskDesc); itemA.addNode(itemA.taskName,itemA.taskDesc); itemA.deleteNode(itemA.taskName,itemA.taskDesc); itemA.printList(); Item *itemPtr;*/ //Queue fam; //fam.menu(); //fam.enqueue(fam.name); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started