/**** * * Definition of the type Planet and associated functions. A Planet is a * struct, with a name, diameter, number of moons, orbit time, and rotation * time. It has functions to read from stdio, print to stdout, change the * value of any component, and test if the components are all empty. * */ /** * Constant for the maximum size-1 of a planet name. */ #define NAME_SIZE 101 /** * Type Planet is a structure that defines the properties of a planet. */ typedef struct { char name[NAME_SIZE]; /* name of the planet */ double diameter; /* equatorial diameter in km */ int moons; /* number of moons */ double orbit_time; /* years to orbit sun once */ double rotation_time; /* hours to complete one revolution on axis */ } Planet; /** * Return a pointer to a new planet, with fields initialized to the given * values. */ Planet* new_planet(char* name, double diameter, int moons, double orbit_time, double rotation_time); /** * Input the components of a planet from stdin, returning the planet value. */ Planet* read_planet(); /** * Print the components of the given planet to stdout. */ void print_planet(Planet* p); /** * Change the name of the given planet to the given name. */ void change_name(Planet* p, char* name); /** * Change the diameter of the given planet to the given diameter. */ void change_diameter(Planet* p, double diameter); /** * Change the moons of the given planet to the given moons value. */ void change_moons(Planet* p, int moons); /** * Change the orbit_time of the given planet to the given orbit_time. */ void change_orbit_time(Planet* p, double orbit_time); /** * Change the rotation_time of the given planet to the given rotation_time. */ void change_rotation_time(Planet* p, double rotation_time); /** * Return true if the given planet is equal to the EMPTY_PLANET, false * otherwise. */ int is_empty(Planet* p);