/****
 *
 * Test some of the SolarSystem functions.  Note that this program performs
 * some initial tests, that do not exhaustively test the functionality of
 * SolarSystem functions.
 *
 */

#include "solar-system.h"
#include <stdio.h>

int main() {
    SolarSystem ss;                          /* Our solar system */
    Planet mercury =                         /* The planet mercury */
        {"mercury", 4878, 0, .241, 1406.4};
    Planet earth =                           /* The planet earth */
        {"earth", 12715.43, 1, 1, 24};

    /*
     * Initialize the system.
     */
    init_system(&ss, 2.874E9, "milky way");

    /*
     * Add mercury first, thereby putting it in the first empty position.
     */
    add_planet(mercury, &ss);

    /*
     * Put earth at position 3 (which is index 2 in C terms).
     */
    put_planet(earth, 2, &ss);

    /*
     * Read in jupiter values and put at position 5 (index 4).
     */
    printf("Input values for planet jupiter:\n");
    put_planet(read_planet(), 4, &ss);

    /*
     * Print out the system so far; other planets are yet to be added.
     */
    printf("\nSolar system with three planets:\n\n");
    print_system(ss);
    printf("\n");

    /*
     * Some tests of the solar system functions.
     */
    printf("Calling find_planet(\"earth\") yields:\n");
    print_planet(find_planet("earth", ss));
    printf("\n");

    printf("Position of planet earth: %d\n", find_planet_position("earth", ss));
    printf("\n");

    remove_planet("earth", &ss);
    printf("After removal, calling find_planet(\"earth\") yields:\n");
    print_planet(find_planet("earth", ss));
    printf("\n");

    return 0;
}