Yes, I know that this is homework. But I need help. This is code the teacher gave us few days ago. This is a header file. And I needed to do the following:
My problem is that I didn't know how to use my vecetor in my .cpp file. How to add the names into the vector? I now it should be kind of like vectorname.push_back("name"); ???
How do I call my vector to print the names?
I don't know I'm lost and need help. I know that there is people that don't want to help with homework but this homework is already past due , I want to learn... and the teacher will never give us the answers, he gives us a grade and if you didn't learned is not his problem... that's how nuts it is...
So I didn't do it because I had no idea how to do it. I'm 100% new with C++ and my teacher the only thing he does is to read some slides he have and he doesn't explain anything. And I don't have anyone to ask. I don't really like my instructor. But I cannot drop the class. Please help me to understand how to call vectors, how to print them, how to do the killing thing. Need help !!! I want to learn. I already did pretty bad in my test :S
• develops a list of twenty unique names, one of them being Josephus
• simulates the stated problem with an arbitrary positive count m (how far to count around the
circle) and a list of n (10 <= n <= 20) named individuals (you may pick the names), listing
these n individuals in the order in which the lot falls upon each.
o Include Josephus in every “game”, regardless of the value of n; Josephus is allowed
to die, and his original position in the circle does not matter
o For n people, the returned list should contain n individuals
• for arbitrary numbers m (m > 0) and n (10 <= n <= 20), computes where Josephus should
stand to be the last one chosen; this location is referred to as the “safe index”, the location
that would be chosen last should the game be played with the specified m and n
--------------------------------------…
#pragma once
#ifndef CIRCLE //Do not modify this line
#define CIRCLE //Do not modify this line
//You may add "#include" statements here
#include <string>
#include <vector>
#include <iostream>
using namespace std; //Do not modify this line
class Circle //Do not modify this line
{ //Do not modify this line
//You may insert visibility modifiers anywhere within this document
//You may declare member variables anywhere within this document
//-----------------------------------…
Circle(); //Do not modify this line
~Circle(){} //Do not modify this line
//-----------------------------------…
/*
getNames
Returns a list of names in the order in which the people will be standing for the "game".
Although fewer people may be playing, you must return 20 names here. Do not provide
duplicate names.
For the sake of the test driver, this method must return the list of 20 names in the
same order every time it is called, and this list of 20 names in this order must be used
to play the "game".
This method will be called repeatedly.
*/
vector<string> getNames(); //Do not modify this line
//You may not implement this method here; you must do so in a .cpp document
/*
playGame
Plays a "game" with the first n people from the list (above) counting forward every m. An
explanation for how the "game" works can be found in the exam specs.
This method should return a list of names in the order in which the lot fell upon them (including
the survivor, who should be last). If n is not between 10 and 20 or if m is non-positive,
return an empty vector.
This method will be called repeatedly.
*/
vector<string> playGame(int n, int m); //Do not modify this line
//You may not implement this method here; you must do so in a .cpp document
/*
reportSafeIndex
Returns the "safe index", the last index/location in the circle that will be chosen when
the "game" is played. The point of this method is to permit someone to cheat the system
by finding the safe location ahead of time.
If n is not between 10 and 20 or if m is non-positive, return -1.
This method may be called repeatedly.
*/
int reportSafeIndex(int n, int m); //Do not modify this line
//You may not implement this method here; you must do so in a .cpp document
//-----------------------------------…
}; //Do not modify this line
#endif //Do not modify this line