Sha256: 6a651628fa7accdacc4ba9e9ae66e3f5010b464c91951b3e53d277f4096bf753

Contents?: true

Size: 1.34 KB

Versions: 396

Compression:

Stored size: 1.34 KB

Contents

#include "space_age.h"

namespace space_age
{

namespace
{
const double earth_years_per_second = 1.0/31557600.0;
const double earth_years_per_mercury_year = 0.2408467;
const double earth_years_per_venus_year = 0.61519726;
const double earth_years_per_mars_year = 1.8808158;
const double earth_years_per_jupiter_year = 11.862615;
const double earth_years_per_saturn_year = 29.447498;
const double earth_years_per_uranus_year = 84.016846;
const double earth_years_per_neptune_year = 164.79132;
}

space_age::space_age(unsigned long long secs)
    : seconds_(secs)
{
}

unsigned long long space_age::seconds() const
{
    return seconds_;
}

double space_age::on_earth() const
{
    return seconds_*earth_years_per_second;
}

double space_age::on_mercury() const
{
    return on_earth()/earth_years_per_mercury_year;
}

double space_age::on_venus() const
{
    return on_earth()/earth_years_per_venus_year;
}

double space_age::on_mars() const
{
    return on_earth()/earth_years_per_mars_year;
}

double space_age::on_jupiter() const
{
    return on_earth()/earth_years_per_jupiter_year;
}

double space_age::on_saturn() const
{
    return on_earth()/earth_years_per_saturn_year;
}

double space_age::on_uranus() const
{
    return on_earth()/earth_years_per_uranus_year;
}

double space_age::on_neptune() const
{
    return on_earth()/earth_years_per_neptune_year;
}

}

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.138 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.137 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.136 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.135 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.134 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.133 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.132 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.131 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.130 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.129 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.128 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.127 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.126 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.125 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.124 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.123 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.122 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.121 tracks/cpp/exercises/space-age/example.cpp
trackler-2.2.1.120 tracks/cpp/exercises/space-age/example.cpp