-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplanHowTheAppWorks.example.txt
158 lines (80 loc) · 2.77 KB
/
planHowTheAppWorks.example.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
This plaintext document outlines my thought process while designing
this application.
Solar-year = 365 Earth-days
Let's not consider leap years. In fact we'll only work with units of
years, not days.
Expected input:
- User's age
- User's life expectancy
- User does not pick a planet
For each planet listed in the next section below, output this:
- The user's age in that planet's years.
- The user's years remaining to live, based on that planet's
years. OR
- The user's years lived past their life expectancy, based on that
planet's years.
To achieve that, do this:
Define a class object constructor PlanetOrbits with the following
properties and values as constants.
Planet Planet's year in Earth years
Mercury 0.24
Venus 0.62
Mars 1.88
Jupiter 11.86
Define a class object constructor UserAgeAndLifeExpectancy with
initial properties:
- userAgeInput
- userLifeExpectancyInput
Additional properties can be added from methods defined below.
Instantiate a class object planetOrbits from its constructor.
Instantiate a class object userAgeAndLifeExpectancy from its
constructor.
Define a method earthYearsRemainingToLive to subtract the user's
current age from the life expectancy they entered to get Earth years
remaining to live. If the user's age is higher than their life
expectancy, instead output the number of years the user has lived past
their life expectancy.
Output:
- userEarthYearsRemainingToLive OR
- earthYearsLivedPastTheLifeExpectancy
Add one of those variables, with its value, as a new third property to
the object userAgeAndLifeExpectancy.
Define a method convertEarthYearsToOtherPlanetYears to loop through
each of these inputs:
- userAgeInput
- userLifeExpectancyInput
- userEarthYearsRemainingToLive OR
- earthYearsLivedPastTheLifeExpectancy
For each planet, multiply or divide the number value by the constant
stored for that planet property in object planetOrbits.
For example, here is how it would look with
userEarthYearsRemainingToLive:
Mercury:
- ageInMercuryYears
- mercuryYearsRemainingToLive
Venus:
- ageInVenusYears
- venusYearsRemainingToLive
Mars:
- ageInMarsYears
- marsYearsRemainingToLive
Jupiter:
- ageInJupiterYears
- jupiterYearsRemainingToLive
As a second example, here is how it would look with
earthYearsLivedPastTheLifeExpectancy:
Mercury:
- ageInMercuryYears
- mercuryYearsLivedPastTheLifeExpectancy
Venus:
- ageInVenusYears
- venusYearsLivedPastTheLifeExpectancy
Mars:
- ageInMarsYears
- marsYearsLivedPastTheLifeExpectancy
Jupiter:
- ageInJupiterYears
- jupiterYearsLivedPastTheLifeExpectancy
As the loop progresses, add each variable and value as a new property
to the object userAgeAndLifeExpectancy.
Display the results to the user.