//
//  main.cpp
//  FriendFunctions
//
//  Created by Robert Metcalfe on 21/07/13.
//  Copyright (c) 2013 Robert Metcalfe. All rights reserved.
//

//
//  main.cpp
//  acircle
//
//  Created by Robert Metcalfe on 03/04/13.
//  Copyright (c) 2013 Robert Metcalfe. All rights reserved.
//
#include <iostream>
void myFriendMoveFunction(double, double);

class point {
private:
    double x, y;
    friend void myFriendMoveFunction(double, double);
public:
    point(double xi, double yi) { x = xi;  y =yi; }
    double getx() { return x; }
    double gety() { return y; }
    void print () { std::cout <<" x "<<x<<" y "<<y<<std::endl; } };

class acircle {
private:
    double x, y, radius;
    friend void myFriendMoveFunction(double, double);
public:
    acircle() { x = 0.0;  y = 0.0;  radius = 1.0; }
    acircle(double xr) { x = 0.0;  y = 0.0;  radius = xr; }
    acircle(double xi, double yi) { x = xi;  y =yi;  radius = 1.0; }
    acircle(double xi, double yi, double xr) { x = xi;  y =yi;  radius = xr; }
    acircle(point p, double xr) { x = p.getx();  y = p.gety();  radius = xr; }
    double getx() { return x; }
    double gety() { return y; }
    void print () { std::cout <<" x "<<x<<" y "<<y<<" radius "<<radius<<std::endl; } };

point a(10.7, 20.0);
acircle c(a, 10.0);

void myFriendMoveFunction(double xoffset, double yoffset) {
    a.x += xoffset;
    a.y += yoffset;
    c.x += xoffset;
    c.y += yoffset;   }

int main(int argc, const char * argv[]) {
    a.print();
    c.print();
    myFriendMoveFunction(-1.0, 2.0);
    a.print();
    c.print();    
    return 0;
}
