Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
Project 3 Star Gazing
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Eric Walsh
Project 3 Star Gazing
Commits
609f776a
Commit
609f776a
authored
Mar 13, 2019
by
Brandon Reid
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autosave
parent
18baea72
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
191 deletions
+10
-191
Functions.cpp
Functions.cpp
+0
-187
Input stuff/Functions.cpp
Input stuff/Functions.cpp
+6
-3
Input stuff/Functions.h
Input stuff/Functions.h
+4
-1
No files found.
Functions.cpp
deleted
100644 → 0
View file @
18baea72
#include "Functions.h"
#include <string>
#include <iostream>
#include <vector>
#include <cmath>
#include <utility>
using
namespace
std
;
// Input checking functions
int
yearPrompt
(
int
year
)
{
do
{
cout
<<
"Enter year: "
;
if
(
!
(
cin
>>
year
))
{
// validates that numbers were entered and checks input
cerr
<<
"Error! Please enter a valid integar."
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
if
(
year
>
0
&&
year
<
9099
)
{
return
year
;
}
else
{
cerr
<<
"Error! Invalid year. Please enter a year between 1 and 9099"
<<
endl
;
}
}
while
(
true
);
}
string
monthPrompt
(
string
month
)
{
do
{
cout
<<
"Enter month: "
;
cin
>>
month
;
if
(
month
==
"January"
||
month
==
"February"
||
month
==
"March"
||
month
==
"April"
||
month
==
"May"
||
month
==
"June"
||
month
==
"July"
||
month
==
"August"
||
month
==
"September"
||
month
==
"October"
||
month
==
"November"
||
month
==
"December"
)
{
return
month
;
}
else
{
cerr
<<
"Error! Please enter a valid month."
<<
endl
;
}
}
while
(
true
);
}
int
dayPrompt
(
string
month
,
int
day
)
{
do
{
cout
<<
"Enter day: "
;
if
(
!
(
cin
>>
day
))
{
// validates that numbers were entered and checks input
cerr
<<
"Error! Please enter a valid integar."
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
if
(
month
==
"January"
||
month
==
"March"
||
month
==
"May"
||
month
==
"July"
||
month
==
"August"
||
month
==
"October"
||
month
==
"December"
)
{
if
(
day
>
0
&&
day
<=
31
)
{
return
day
;
}
}
if
(
month
==
"April"
||
month
==
"June"
||
month
==
"September"
||
month
==
"November"
)
{
if
(
day
>
0
&&
day
<=
30
)
{
return
day
;
}
}
if
(
month
==
"February"
)
{
if
(
day
>
0
&&
day
<=
28
)
{
return
day
;
}
}
cerr
<<
"Error! Please enter a valid date."
<<
endl
;
}
while
(
true
);
}
int
hourPrompt
(
int
hour
)
{
do
{
cout
<<
"Enter hour (0 - 24): "
;
if
(
!
(
cin
>>
hour
))
{
// validates that numbers were entered and checks input
cerr
<<
"Error! Please enter a valid integer."
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
if
(
hour
>
0
&&
hour
<=
24
)
{
return
hour
;
}
else
{
cerr
<<
"Error! Please enter a valid hour."
<<
endl
;
}
}
while
(
true
);
}
int
minutePrompt
(
int
minute
)
{
do
{
cout
<<
"Enter minute: "
;
if
(
!
(
cin
>>
minute
))
{
// validates that numbers were entered and checks input
cerr
<<
"Error! Please enter a valid integer."
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
if
(
minute
>=
0
&&
minute
<
60
)
{
return
minute
;
}
else
{
cerr
<<
"Error! Please enter a valid minute."
<<
endl
;
}
}
while
(
true
);
}
double
dateToHour
(
string
month
,
int
day
,
int
hour
,
int
minute
)
{
// Converts the date into hours
//variables
double
totHours
=
0
;
int
monthNum
=
0
;
if
(
month
==
"January"
)
{
monthNum
=
1
;
}
else
if
(
month
==
"February"
)
{
monthNum
=
2
;
}
else
if
(
month
==
"March"
)
{
monthNum
=
3
;
}
else
if
(
month
==
"April"
)
{
monthNum
=
4
;
}
else
if
(
month
==
"May"
)
{
monthNum
=
5
;
}
else
if
(
month
==
"June"
)
{
monthNum
=
6
;
}
else
if
(
month
==
"July"
)
{
monthNum
=
7
;
}
else
if
(
month
==
"August"
)
{
monthNum
=
8
;
}
else
if
(
month
==
"September"
)
{
monthNum
=
9
;
}
else
if
(
month
==
"October"
)
{
monthNum
=
10
;
}
else
if
(
month
==
"November"
)
{
monthNum
=
11
;
}
else
{
monthNum
=
12
;
}
totHours
+=
(
monthNum
*
730
)
+
(
day
*
24
)
+
(
minute
/
60
);
return
totHours
;
}
bool
isLeap
(
int
year
)
{
}
pair
<
double
,
double
>
altAndAziPair
(
double
altitude
,
string
Direction
)
{
double
Azi
;
pair
<
double
,
double
>
aziPair
;
do
{
cout
<<
"Enter the altitude at which you are looking (0-90): "
;
if
(
!
(
cin
>>
altitude
))
{
// validates that numbers were entered and checks input
cerr
<<
"Error! Please enter a valid integer."
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
else
if
(
altitude
<
0
||
altitude
>=
90
)
{
cout
<<
"Please put in a valid value."
<<
endl
;
}
}
while
(
false
)
do
{
cout
<<
"Enter a cardinal direction (North, South, East, West, Northeast, Southeast, Southwest, or Northwest): "
;
cin
>>
Direction
;
if
(
Direction
!=
"North"
||
Direction
!=
"South"
||
Direction
!=
"East"
||
Direction
!=
"West"
||
Direction
!=
"Northeast"
||
Direction
!=
"Southeast"
||
Direction
!=
"Southwest"
||
Direction
!=
"Northwest"
)
{
cout
<<
"Error! Please input a valid direction"
;
}
}
while
(
Direction
!=
"North"
||
Direction
!=
"South"
||
Direction
!=
"East"
||
Direction
!=
"West"
||
Direction
!=
"Northeast"
||
Direction
!=
"Southeast"
||
Direction
!=
"Southwest"
||
Direction
!=
"Northwest"
)
if
(
Direction
==
"North"
)
{
Azi
=
0
;
}
else
if
(
Direction
==
"South"
)
{
Azi
=
180
;
}
else
if
(
Direction
==
"East"
)
{
Azi
=
90
;
}
else
if
(
Direction
==
"West"
)
{
Azi
=
270
;
}
else
if
(
Direction
==
"Northeast"
)
{
Azi
=
45
;
}
else
if
(
Direction
==
"Southeast"
)
{
Azi
=
135
;
}
else
if
(
Direction
==
"Southwest"
)
{
Azi
=
225
;
}
else
if
(
Direction
==
"Northwest"
)
{
Azi
=
315
;
}
aziPair
=
make_pair
(
altitude
,
Azi
);
return
aziPair
;
}
Input stuff/Functions.cpp
View file @
609f776a
...
...
@@ -121,10 +121,13 @@ pair<double,double> altAndAziPair (double altitude, string Direction) {
cin
.
clear
();
cin
.
ignore
(
1000
,
'\n'
);
continue
;
}
else
if
(
altitude
<
0
||
altitude
>=
90
)
{
cout
<<
"Please put in a valid value."
<<
endl
;
}
if
(
altitude
>=
0
&&
altitude
<=
90
)
{
break
;
}
else
{
cerr
<<
"Please put in a valid value."
<<
endl
;
}
}
while
(
false
)
}
while
(
true
);
do
{
cout
<<
"Enter a cardinal direction (North, South, East, West, Northeast, Southeast, Southwest, or Northwest): "
;
...
...
Input stuff/Functions.h
View file @
609f776a
...
...
@@ -15,4 +15,7 @@ int minutePrompt (int minute);
double
dateToHour
(
string
month
,
int
day
,
int
hour
,
int
minute
);
bool
isLeap
(
int
year
);
\ No newline at end of file
pair
<
double
,
double
>
altAndAziPair
(
double
altitude
,
string
Direction
);
bool
isLeap
(
int
year
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment