1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
grin007 [14]
3 years ago
13

Building the Trivia Game You will be writing a program that implements a trivia game. The program will need two classes: the Que

stion class and the TriviaGame class. Question class The Question class represents one question and the possible answers for that question. The Question class contains the question text and the 4 possible answers. It also contains the answer number of the correct answer. The answer number is an unsigned int in the range of 1 to 4. You need to design the Question class. What behaviors does it need
Computers and Technology
1 answer:
postnew [5]3 years ago
3 0

Answer:

/Question.h

#include<iostream>

#include<string>

using namespace std;

 

class Question

{

private:

string question;

string answer[4];

unsigned int correctAnswer;

public:

Question(string ques,string *ans,unsigned int x)

{

int i;

question.assign(ques);

for(i=0;i<4;i++)

{

answer[i]=ans[i];

}

correctAnswer=x;

}

~Question()

{

}

string getQuestion()

{

return question;

}

unsigned int getCorrectAnswer()

{

return correctAnswer;

}

string getAnswer1()

{

return answer[0];

}string getAnswer2()

{

return answer[1];

}

string getAnswer3()

{

return answer[2];

}string getAnswer4()

{

return answer[3];

}

int getNoOfPossibleAnswers()

{

return 4;

}

};

Explanation:

The Question class represents one question and the possible answers for that question.

The Question class contains the question text and the 4 possible answers. It also contains the answer number of the correct answer.

The answer number is an unsigned int in the range of 1 to 4.Your Question class needs to have one or more constructors and one destructor.

It needs a member function that returns the question text. It also needs member functions that return the answer text for a specific answer

(1 through 4). The class also needs a member function that returns the number of possible answers for this question. While this is 4 today,

it could change in future versions of the class. Finally there needs to be a member function that returns the answer number of the correct answer

(a value of 1 through 4).Do not make the data members public. You can have public and private member functions as needed.

You might be interested in
You open a web page and log into your email. The traffic travels over many routers. What protocol will the routers use to determ
exis [7]

Answer:

Border Gateway Protocol is a protocol the routers use to determine the most optimal path to forward the traffic.

Explanation:

BGP is a path vector protocol which chooses the most optimal path. The protocol decides core routing decisions based on path, configuration and network.

This protocol gives all the notification about the status of the connection and router.

It is used to routing in an autonomous system and provides ways to measure the effectiveness of configuration.

6 0
3 years ago
refers to a problem-solving approach that requires defining the scope of a system, dividing it into its components, and then ide
lilavasa [31]

Answer:

D. System Analysis

Explanation:

System analysis can be defined as the process of analysing a problem in order to the know the cause thereby finding a way to resolve it or finding a solution to it.

System analysis enables us to easily study procedure or process thereby identifying what the objective of the procedures is which will in turn help to achieve what we needed to achieve.

System analysis is important because it enables easier identification of a problem which make us to find the best way to solve the problem since it is a problem solving technique which ensures that all problem are been resolved accurately and efficiently

6 0
3 years ago
What's the problem with this code ?
Svet_ta [14]
Hi,

I changed your program using some of the concepts you were trying to use. Hopefully you can see how it works:

#include <string>
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
   short T;
   cin >> T;
   cin.ignore();

   string str[100];

   for(int i=0; i<T; i++)
   {
      getline(cin, str[i]);
   }

   for (int i = 0; i < T; i++)
   {
      stringstream ss(str[i]);
      string tmp;
      vector<string> v;

      while (ss >> tmp)
      {
          // Let's capitalize it before storing in the vector
          if (!tmp.empty())
          {
              transform(begin(tmp), end(tmp), std::begin(tmp), ::tolower);
              tmp[0] = toupper(tmp[0]);
           }
           v.push_back(tmp);
        }

        if (v.size() == 1)
        {
           cout << v[0] << endl;
        }
        else if (v.size() == 2)
        {
           cout << v[0][0] << ". "  << v[1] << endl;
        }
        else
        {
            cout << v[0][0] << ". " << v[1][0] << ". " << v[2] << endl;
        }
    }

     return 0;
}

4 0
3 years ago
What is the main task of the project manager
WINSTONCH [101]

Answer:

to handle day to day operations of a project A P E X

Explanation:

hope that helped

6 0
3 years ago
Read 2 more answers
When the national economy goes from bad to better, market research shows changes in the sales at various types of restaurants. P
zhannawk [14.2K]

Answer: it will be greater by $2.6 billion

Explanation:

7 0
4 years ago
Other questions:
  • Which relationship is possible when two tables share the same primary key? one-to-one one-to-many many-to-one many-to-many
    15·2 answers
  • _____ is defined as an attraction for a source based on a resemblance between the source and receiver of a message.
    15·1 answer
  • Help with what the awnser is
    10·1 answer
  • Boardman College maintains two files—one for Sociology majors and another for Anthropology majors. Each file contains students'
    5·1 answer
  • How does emotional awareness help you with non-verbal communication?
    13·2 answers
  • What are the advantages of Napier bones?​
    15·1 answer
  • Which term describes the second core IPSec security protocol; it can perform authentication to provide integrity protection, alt
    13·1 answer
  • Which value can be entered to cause the following code segment to display the message "That number is acceptable."? ____.
    15·1 answer
  • What is a Software that interprets commands drom the keyboard and mouse
    13·1 answer
  • Everyone within a company needs to be aware of what data can do to improve business processes and how to make it happen. Which c
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!