Toggle navigation
Toggle navigation
This project
Loading...
Sign in
전현진
/
21.03.26_HW
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
전현진
2021-03-26 21:53:34 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b4876c36ddab20ab7ffab7114cb63d06e818d2b8
b4876c36
1 parent
4095fd2e
add exit function
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
2 deletions
EchoProgram/EchoString.cpp
EchoProgram/EchoString.h
EchoProgram/main.cpp
EchoProgram/EchoString.cpp
View file @
b4876c3
#include "EchoString.h"
const
std
::
string
EchoString
::
mExitMessage
=
"exit"
;
void
EchoString
::
PrintScreen
()
{
std
::
cout
<<
"Echo Program : "
;
...
...
@@ -8,9 +10,9 @@ void EchoString::PrintScreen()
void
EchoString
::
InputString
()
{
while
(
getEcho
().
empty
()
)
while
(
true
)
{
std
::
cout
<<
"Input your string : "
;
std
::
cout
<<
"Input your string
(EXIT :
\"
exit
\"
)
: "
;
std
::
getline
(
std
::
cin
,
mEcho
);
if
(
std
::
cin
.
fail
())
...
...
@@ -20,6 +22,8 @@ void EchoString::InputString()
system
(
"cls"
);
continue
;
}
break
;
}
}
...
...
EchoProgram/EchoString.h
View file @
b4876c3
...
...
@@ -7,6 +7,7 @@ class EchoString
{
private
:
std
::
string
mEcho
;
static
const
std
::
string
mExitMessage
;
public
:
void
PrintScreen
();
...
...
@@ -19,6 +20,7 @@ public:
void
setEcho
(
const
std
::
string
&
echo
)
{
mEcho
=
echo
;
}
std
::
string
getEcho
()
const
{
return
mEcho
;
}
std
::
string
getEcho
()
{
return
mEcho
;
}
std
::
string
getExitMessage
()
{
return
mExitMessage
;
}
};
...
...
EchoProgram/main.cpp
View file @
b4876c3
...
...
@@ -7,8 +7,14 @@ int main()
{
EchoString
echo
;
while
(
true
)
{
echo
.
InputString
();
if
(
echo
.
getEcho
()
==
echo
.
getExitMessage
())
break
;
echo
.
PrintScreen
();
}
return
0
;
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment