Пример #1
0
void Ship::shotFiredAtPoint(const point& p)
{
	IntCollection hits;
	if points.collidesWith(p)
	{
		hits.add(p);
	}
Пример #2
0
int main(int argc, char *argv[])
{
  /////// Ints ////////
  IntCollection intCollection;
  for(unsigned int i = 0; i < 4; ++i)
    {
    intCollection.AddItem(i);
    }

  // Single visitor operations
//   SumAccumulator intSumAccumulator;
//   intCollection.Visit(intSumAccumulator);
//   std::cout << "sum: " << intSumAccumulator.Sum << std::endl;
// 
//   AverageAccumulator intAverageAccumulator;
//   intCollection.Visit(intAverageAccumulator);
//   std::cout << "average: " << intAverageAccumulator.Average << std::endl;

  SumAccumulator sumVisitor;
  AverageAccumulator averageVisitor;

  CompositeVisitor compositeVisitor;
  compositeVisitor.AddVisitor(&sumVisitor);
  compositeVisitor.AddVisitor(&averageVisitor);

  return 0;
}
Пример #3
0
//printer helper function to print results of Intcollector
void printCheck (IntCollection &c)
{

    for (int i = 0; i < c.getSize(); i++)
    {
        cout << c.get(i) << endl;
    }
}
Пример #4
0
int main()
{
    IntCollection d;
    IntCollection c;

    c.add(45);
    c.add(-210);
    c.add(77);
    c.add(2);
    c.add(-21);
    c.add(42);
    c.add(7);
    d = c;
    c << 4 << 7 << 9 << 10;
    printCheck(c);
    checkEqual(c,d);

    d << 10 << 4 << 84;
    printCheck(d);
    checkEqual(c,d);
}