Coverage Report: Coaster
File: TicketApp.cpp
show more
show less
From
All Files
Location
C:\Testwell\Coaster\CoasterCode\TicketApp.cpp
MC/DC
69%
23 / 33
Statement
88%
30 / 34
True
Highlight:
All
MC/DC
Statement
False
Source & Details
Show Code:
Outside Functions
Show Coverage Details:
Single Probe Descriptions
Condition Blocks
True-False-Tables
MC/DC Blocks
TicketApp.cpp
All Files
1
#include "TicketApp.h"
2
#include "Kermisvisitor.h"
3
#include <iostream>
4
#include <iomanip>
5
#include <string>
6
7
using
namespace
std;
8
25
34
42
54
66
85
9
void
TicketApp::showInstruction()
1
FUNCTION TicketApp::showInstruction()
10
{
11
system(
"CLS"
);
12
cout <<
"PricingCalculator for Infinity!\n"
;
13
cout <<
"===============================\n\n"
;
14
cout <<
"Please enter first name, age and body height of the potential passenger.\n"
;
15
cout <<
"PricingCalculator decides about admission to the rollercoaster\n"
;
16
cout <<
"and if so what the passenger has to pay for a ticket.\n\n"
;
17
18
string selectedDialogueMode;
19
20
cout << endl <<
"Enter 's' to start."
<< endl;
21
cin >> selectedDialogueMode;
22
23
if
(!(selectedDialogueMode ==
"s"
|| selectedDialogueMode ==
"S"
)) { switch2BatchMode(); }
1
0
if (! ( selectedDialogueMode == "s" || selectedDialogueMode == "S" ))
1
1
!(F || F)
0
2
!(T || _)
0
3
!(F || T)
-
MC/DC
selectedDialogueMode == "s":
1, 2
-
MC/DC
selectedDialogueMode == "S":
1, 3
24
}
1
function end
26
void
TicketApp::switch2BatchMode()
1
FUNCTION TicketApp::switch2BatchMode()
27
{
28
system(
"CLS"
);
29
cout <<
"PricingCalculator for Infinity!\n"
;
30
cout <<
"===============================\n\n"
;
31
runInDialogueMode=
false
;
32
cout <<
"--- Results in Batch Mode ---"
<< endl << endl;
33
}
1
function end
35
void
TicketApp::ask4Input(string theQuestion)
16
FUNCTION TicketApp::ask4Input()
36
{
37
if
(runInDialogueMode)
0
16
if (runInDialogueMode)
38
{
39
cout << theQuestion;
40
}
41
}
16
function end
43
void
TicketApp::reportPrice(Kermisvisitor prvPassenger,
int
thePrice)
3
FUNCTION TicketApp::reportPrice()
44
{
45
if
(runInDialogueMode)
0
3
if (runInDialogueMode)
46
{
47
cout << prvPassenger.FirstName +
", the price for your ride is "
+ to_string(thePrice) +
" EUR."
;
48
}
49
else
else
50
{
51
cout <<
"Passenger "
+ prvPassenger.FirstName +
", "
+ to_string(prvPassenger.Age) +
" years old and "
<< setprecision(3) << prvPassenger.BodyHeight <<
" m tall, has to pay "
+ to_string(thePrice) +
" EUR."
;
52
}
53
}
3
function end
55
void
TicketApp::reportRefusal(Kermisvisitor prvPassenger)
1
FUNCTION TicketApp::reportRefusal()
56
{
57
if
(runInDialogueMode)
0
1
if (runInDialogueMode)
58
{
59
cout << prvPassenger.FirstName +
", sorry you can't get access to the rollercoaster :-("
;
60
}
61
else
else
62
{
63
cout << prvPassenger.FirstName +
" ("
+ to_string(prvPassenger.Age) +
"/"
<< setprecision(3) << prvPassenger.BodyHeight <<
" m), sorry you can't get access to the rollercoaster :-("
;
64
}
65
}
1
function end
67
bool
TicketApp::shallProceed()
4
FUNCTION TicketApp::shallProceed()
68
{
69
string anotherPassenger;
70
71
ask4Input(
" --- One more try (y/n)? "
);
72
cin >> anotherPassenger;
73
cout << endl;
74
75
if
(anotherPassenger ==
"j"
|| anotherPassenger ==
"ja"
|| anotherPassenger ==
"y"
|| anotherPassenger ==
"yes"
)
3
1
if (anotherPassenger == "j" || anotherPassenger == "ja" || anotherPassenger == "y" || anotherPassenger == "yes")
3
1
T || _ || _ || _
0
2
F || T || _ || _
0
3
F || F || T || _
0
4
F || F || F || T
1
5
F || F || F || F
+
MC/DC
anotherPassenger == "j":
1, 5
-
MC/DC
anotherPassenger == "ja":
2, 5
-
MC/DC
anotherPassenger == "y":
3, 5
-
MC/DC
anotherPassenger == "yes":
4, 5
76
{
77
#pragma CTC APPEND
78
return
true
;
3
return true
79
}
80
else
else
81
{
82
return
false
;
1
return false
83
}
84
}
function end
86
void
TicketApp::sayGoodBye()
1
FUNCTION TicketApp::sayGoodBye()
87
{
88
if
(runInDialogueMode)
0
1
if (runInDialogueMode)
89
{
90
cout <<
"Thank you for travelling with Achter-Bahn!"
;
91
}
92
else
else
93
{
94
cout << endl <<
"--- Batch Mode completed! ---"
;
95
}
96
}
1
function end
Overview
❮❮
❮
All Files
PassengerScan.cpp
PriceCalculation.cpp
Rollercoaster.cpp
TicketApp.cpp
Select File
❯
❯❯