Commit 2a744200 authored by Allen B. Doelue's avatar Allen B. Doelue

Upload New File

parent bdbf1e96
#include "Lobby.h"
#include "Player.h"
#include <iostream>
using namespace std;
Lobby::Lobby(){
capacity = 6;
players = new Player[capacity];
size = 0;
rankSum = 0;
}
Lobby::Lobby(unsigned int cap)
{
capacity = cap;
players = new Player[capacity];
size = 0;
rankSum = 0;
}
float Lobby::getAverage() {
if (size == 0) {
return 0;
}
rankSum = 0;
for (int i = 0; i < size; i++) {
rankSum += players[i].getRank();
}
return rankSum / size;
}
void Lobby::addPlayer(Player p){
cout<<"start add"<<endl;
cout<<"player rank: "<<p.getRank()<<endl;
players[size] = p;
cout<<"increase size"<<endl;
size++;
}
void Lobby::display(){
for (unsigned int i = 0; i < size; i++) {
cout<<"Player "<< i+1<<endl;
players[i].displayName();
cout<<players[i].getRank()<<endl;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment