Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
Java2Cpp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Glaser
Java2Cpp
Commits
3659d430
Commit
3659d430
authored
3 years ago
by
tobiglaser
Browse files
Options
Downloads
Patches
Plain Diff
change Command, add Gear, Direction & Pause
parent
b3340bf8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Command.h
+4
-1
4 additions, 1 deletion
src/Command.h
src/Direction.h
+40
-0
40 additions, 0 deletions
src/Direction.h
src/Gear.h
+55
-0
55 additions, 0 deletions
src/Gear.h
src/Pause.h
+37
-0
37 additions, 0 deletions
src/Pause.h
with
136 additions
and
1 deletion
src/Command.h
+
4
−
1
View file @
3659d430
#pragma once
#include
<string>
class
Command
#include
"commandlib.h"
class
Command
:
ICommand
{
private:
std
::
string
name
;
public:
Command
(
std
::
string
_name
)
{
name
=
_name
;
}
std
::
string
getName
()
{
return
name
;
}
virtual
std
::
string
getConfig
()
=
0
;
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Direction.h
0 → 100644
+
40
−
0
View file @
3659d430
#pragma once
#include
"commandlib.h"
#include
"Command.h"
#include
<string>
class
Direction
:
public
Command
,
public
IDirection
{
private:
int
degree
;
public:
Direction
();
Direction
(
int
newDegree
);
void
setDegree
(
int
newDegree
);
int
getDegree
()
{
return
degree
;
}
std
::
string
getConfig
();
};
Direction
::
Direction
(
int
newDegree
)
:
Command
(
IDirection
::
direction
)
{
setDegree
(
newDegree
);
}
void
Direction
::
setDegree
(
int
newDegree
)
{
if
(
newDegree
<=
-
90
)
degree
=
-
90
;
else
if
(
newDegree
>=
90
)
degree
=
90
;
else
degree
=
newDegree
;
}
std
::
string
Direction
::
getConfig
()
{
std
::
string
str
=
IDirection
::
direction
+
" - Degree: "
+
std
::
to_string
(
degree
)
+
'.'
;
return
str
;
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Gear.h
0 → 100644
+
55
−
0
View file @
3659d430
#pragma once
#include
"commandlib.h"
#include
"Command.h"
#include
<string>
class
Gear
:
public
Command
,
public
IGear
{
private:
int
speed
;
double
duration
;
public:
Gear
();
Gear
(
int
newSpeed
,
double
newDuration
);
void
setSpeed
(
int
newSpeed
);
int
getSpeed
()
{
return
speed
;
}
void
setDuration
(
double
newDuration
);
double
getDuration
()
{
return
duration
;
}
std
::
string
getConfig
();
};
Gear
::
Gear
(
int
newSpeed
,
double
newDuration
)
:
Command
(
IGear
::
gear
)
{
setSpeed
(
newSpeed
);
setDuration
(
newDuration
);
}
void
Gear
::
setSpeed
(
int
newSpeed
)
{
if
(
newSpeed
<=
-
100
)
speed
=
-
100
;
else
if
(
newSpeed
>=
100
)
speed
=
100
;
else
speed
=
newSpeed
;
}
void
Gear
::
setDuration
(
double
newDuration
)
{
if
(
newDuration
<
0
)
duration
=
0
;
else
duration
=
newDuration
;
}
std
::
string
Gear
::
getConfig
()
{
std
::
string
str
=
IGear
::
gear
+
" - Speed: "
+
std
::
to_string
(
speed
)
+
" for: "
+
std
::
to_string
(
duration
)
+
's'
;
return
str
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Pause.h
0 → 100644
+
37
−
0
View file @
3659d430
#pragma once
#include
"commandlib.h"
#include
"Command.h"
#include
<string>
class
Pause
:
public
Command
,
public
IPause
{
private:
double
duration
;
public:
Pause
();
Pause
(
double
newDuration
);
void
setDuration
(
double
newDuration
);
double
getDuration
()
{
return
duration
;
}
std
::
string
getConfig
();
};
Pause
::
Pause
(
double
newDuration
)
:
Command
(
IPause
::
pause
)
{
setDuration
(
newDuration
);
}
void
Pause
::
setDuration
(
double
newDuration
)
{
if
(
newDuration
<
0
)
duration
=
0
;
else
duration
=
newDuration
;
}
std
::
string
Pause
::
getConfig
()
{
std
::
string
str
=
IPause
::
pause
+
" - Duration: "
+
std
::
to_string
(
duration
);
return
str
;
};
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment