#C++ code: having trouble with it

1 messages · Page 1 of 1 (latest)

summer garnet
#
#include <iostream>
#include <vector>

#include <cstring>

#include "Task.hpp"
#include "PrioritizedTask.hpp"
#include "TimedTask.hpp"

int main(int argc, char **argv)
{
    std::string subject, description, dueDate, buffer;
    bool completed;
    int priority;
    
    std::cout << "Enter the subject of your task: ";
    getline(std::cin, subject);
    
    std::cout << "Enter the description of your task: ";
    getline(std::cin, description);
    
    // The issue is that you're mixing the >> and getline, this is defo probably not the best solution but hey!
    
    std::cout << "Enter the completion status of your task (0 for not completed, 1 for completed): ";
    getline(std::cin, buffer);
    completed = strcmp(buffer.c_str(), "1") == 0;
    
    Task myTask(subject, description, completed);
    std::cout << "My task is to " << myTask.getSubject() << std::endl;
    std::cout << "Task description: " << myTask.getdescription() << std::endl;
    std::cout << "Completion Status: " << myTask.getCompletionStatus() << std::endl;

    myTask.completedStatus(false);
    myTask.notCompletedStatus(true);
    
    std::cout << "Enter the priority level of your prioritized task: " << std::endl;
    getline(std::cin, buffer);
    priority = std::stoi(buffer.c_str());
    
    PrioritizedTask myPrioritizedTask(priority);
    std::cout << "My prioritized task has a priority level of " << myPrioritizedTask.getPriority() << std::endl;
    
    std::cout << "Enter the due date of your timed task: " << std::endl;
    getline(std::cin, dueDate);
    
    TimedTask myTimedTask(dueDate);
    std::cout << "My timed task is due on " << myTimedTask.getDueDate() << std::endl;
    

    return 0;
}

Try this

languid light
#

OMG thank you

#

i dont know if it is just me but sometimes i think to hard i forget basic stuff sometimes

#

but still ty

summer garnet
#

Np

lusty bison
#

there might be a C++ version of strcmp()