SlideShare a Scribd company logo
1 of 438
Download to read offline
Larry and Jen do
Roman Numerals
in C++
by Jon Jagger and Olve Maudal
http://www.slideshare.net/olvemaudal/deep-c
Larry and Jen first appeared in the popular Deep C (and C++) presentation
Jen, will you help me do
some C++ practice?
Jen, will you help me do
some C++ practice?
Sure Larry.
Given a positive integer number (eg 42) determine
its Roman numeral representation as a String (eg "XLII").
The Roman 'letters' are:
1 -> "I" | 10 -> "X" | 100 -> "C" | 1000 -> "M"
2 -> "II" | 20 -> "XX" | 200 -> "CC" | 2000 -> "MM"
3 -> "III" | 30 -> "XXX" | 300 -> "CCC" | 3000 -> "MMM"
4 -> "IV" | 40 -> "XL" | 400 -> "CD" | 4000 -> "MMMM"
5 -> "V" | 50 -> "L" | 500 -> "D"
6 -> "VI" | 60 -> "LX" | 600 -> "DC"
7 -> "VII" | 70 -> "LXX" | 700 -> "DCC"
8 -> "VIII" | 80 -> "LXXX" | 800 -> "DCCC"
9 -> "IX" | 90 -> "XC" | 900 -> "CM"
You cannot write numerals like IM for 999.
Wikipedia states "Modern Roman numerals are written by
expressing each digit separately starting with the
leftmost digit and skipping any digit with a value of zero."
Examples:
o) 1990 -> "MCMXC" (1000 -> "M" + 900 -> "CM" + 90 -> "XC")
o) 2008 -> "MMVIII" (2000 -> "MM" + 8 -> "VIII")
o) 99 -> "XCIX" ( 90 -> "XC" + 9 -> "IX")
o) 47 -> "XLVII" ( 40 -> "XL" + 7 -> "VII")
How about the roman
numerals kata?
Given a positive integer number (eg 42) determine
its Roman numeral representation as a String (eg "XLII").
The Roman 'letters' are:
1 -> "I" | 10 -> "X" | 100 -> "C" | 1000 -> "M"
2 -> "II" | 20 -> "XX" | 200 -> "CC" | 2000 -> "MM"
3 -> "III" | 30 -> "XXX" | 300 -> "CCC" | 3000 -> "MMM"
4 -> "IV" | 40 -> "XL" | 400 -> "CD" | 4000 -> "MMMM"
5 -> "V" | 50 -> "L" | 500 -> "D"
6 -> "VI" | 60 -> "LX" | 600 -> "DC"
7 -> "VII" | 70 -> "LXX" | 700 -> "DCC"
8 -> "VIII" | 80 -> "LXXX" | 800 -> "DCCC"
9 -> "IX" | 90 -> "XC" | 900 -> "CM"
You cannot write numerals like IM for 999.
Wikipedia states "Modern Roman numerals are written by
expressing each digit separately starting with the
leftmost digit and skipping any digit with a value of zero."
Examples:
o) 1990 -> "MCMXC" (1000 -> "M" + 900 -> "CM" + 90 -> "XC")
o) 2008 -> "MMVIII" (2000 -> "MM" + 8 -> "VIII")
o) 99 -> "XCIX" ( 90 -> "XC" + 9 -> "IX")
o) 47 -> "XLVII" ( 40 -> "XL" + 7 -> "VII")
How about the roman
numerals kata?
ok
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
to_roman.tests.cpp
I'll start with a test.
1 should be I.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
to_roman.tests.cpp
I'll start with a test.
1 should be I.#include "to_roman.hpp"
#include <cassert>
#include <iostream>
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
to_roman.tests.cpp
I'll start with a test.
1 should be I.#include "to_roman.hpp"
#include <cassert>
#include <iostream>
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
Here's my header file, to_roman.hpp
#ifndef TO_ROMAN_INCLUDED
#define TO_ROMAN_INCLUDED
#include <string>
std::string to_roman(int number);
#endif
Here's my header file, to_roman.hpp
#ifndef TO_ROMAN_INCLUDED
#define TO_ROMAN_INCLUDED
#include <string>
std::string to_roman(int number);
#endif
Here's my header file, to_roman.hpp
Here's my source file, to_roman.cpp
#ifndef TO_ROMAN_INCLUDED
#define TO_ROMAN_INCLUDED
#include <string>
std::string to_roman(int number);
#endif
Here's my header file, to_roman.hpp
Here's my source file, to_roman.cpp
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "";
}
#ifndef TO_ROMAN_INCLUDED
#define TO_ROMAN_INCLUDED
#include <string>
std::string to_roman(int number);
#endif
Here's my header file, to_roman.hpp
ok
Here's my source file, to_roman.cpp
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "";
}
How are you building and running?
How are you building and running?
With this.
How are you building and running?
$ cc *.cpp && ./a.out
With this.
How are you building and running?
$ cc *.cpp && ./a.out
With this.
Try it.
How are you building and running?
$ cc *.cpp && ./a.out
With this.
Try it.
$ cc *.cpp && ./a.out
All tests passed
How are you building and running?
$ cc *.cpp && ./a.out
With this.
Try it.
$ cc *.cpp && ./a.out
All tests passed
Eh? That's not right. It
should have failed!
How are you building and running?
$ cc *.cpp && ./a.out
With this.
Try it.
$ cc *.cpp && ./a.out
All tests passed
Eh? That's not right. It
should have failed!
Let's see the tests again.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
That's easy to fix.
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
That's easy to fix.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
That's easy to fix.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
test_1_is_I();
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
$ cc *.cpp && ./a.out
That's easy to fix.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
test_1_is_I();
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
$ cc *.cpp && ./a.out$ cc *.cpp && ./a.out
Assertion failed: (to_roman(1) == "I")
That's easy to fix.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
test_1_is_I();
Of course.We're not
calling the test! #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
Hmmmm.
$ cc *.cpp && ./a.out$ cc *.cpp && ./a.out
Assertion failed: (to_roman(1) == "I")
That's easy to fix.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
std::cout << "All tests passed"
<< std::endl;
}
test_1_is_I();
Now it fails.
I can simply change the
the return value to
make it pass.
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "";
}
I can simply change the
the return value to
make it pass.
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
I can simply change the
the return value to
make it pass.
$ cc *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
I can simply change the
the return value to
make it pass.
$ cc *.cpp && ./a.out$ cc *.cpp && ./a.out
All tests passed
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
I can simply change the
the return value to
make it pass.
$ cc *.cpp && ./a.out$ cc *.cpp && ./a.out
All tests passed
ok
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
Let's write another test.
2 should be II
I think there is a problem we
should fix first.
Let's write another test.
2 should be II
I think there is a problem we
should fix first.
Let's write another test.
2 should be II
What problem?
I think there is a problem we
should fix first.
Let's write another test.
2 should be II
What problem?
We've fixed the immediate
issue by calling the function.
But what happens the next
time we forget?
I think there is a problem we
should fix first.
Let's write another test.
2 should be II
What problem?
We've fixed the immediate
issue by calling the function.
But what happens the next
time we forget?
What do you suggest?
Could the compiler detect when
we have a function that is defined
but not used?
Could the compiler detect when
we have a function that is defined
but not used?
A command line option?
Yes. It's one of the smells the
compiler can detect with the
-Wall flag.
Could the compiler detect when
we have a function that is defined
but not used?
A command line option?
Yes. It's one of the smells the
compiler can detect with the
-Wall flag.
ok. Let me try that.
Could the compiler detect when
we have a function that is defined
but not used?
A command line option?
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call #include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
and add the
-Wall flag
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
$ cc *.cpp && ./a.out
and add the
-Wall flag
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
$ cc *.cpp && ./a.out
and add the
-Wall flag
$ cc *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
$ cc *.cpp && ./a.out
and add the
-Wall flag
$ cc *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
-Wall
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
$ cc *.cpp && ./a.out
and add the
-Wall flag
$ cc *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
-Wall$ cc -Wall *.cpp && ./a.out
warning: 'void test_1_is_I()' is
defined but not used
All tests passed
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll comment out the call
$ cc *.cpp && ./a.out
and add the
-Wall flag
$ cc *.cpp && ./a.out
now I get the warning
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
-Wall$ cc -Wall *.cpp && ./a.out
warning: 'void test_1_is_I()' is
defined but not used
All tests passed
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
Agreed.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall *.cpp && ./a.out
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
Agreed.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall *.cpp && ./a.out
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
$ cc -Wall *.cpp && ./a.out
Agreed.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall *.cpp && ./a.out
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
$ cc -Wall *.cpp && ./a.out-Werror
Agreed.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall *.cpp && ./a.out
Turning the warning into an
error would be even better.
We can do that with the
-Werror flag
$ cc -Wall *.cpp && ./a.out-Werror$ cc -Wall -Werror *.cpp && ./a.out
error: 'void test_1_is_I()' is defined
but not used
Agreed.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
//test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
I'll uncomment the comment so the
test passes again.
Now we can write
the next test.
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
/test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
#include "to_roman.hpp"
#include <cassert>
#include <iostream>
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
It should fail because
to_roman still always
returns "I"
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
$ cc -Wall -Werror *.cpp && ./a.out
It should fail because
to_roman still always
returns "I"
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
void test_2_is_II(): Assertion
`to_roman(2) == "II"' failed.
It should fail because
to_roman still always
returns "I"
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
2 should be II
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
void test_2_is_II(): Assertion
`to_roman(2) == "II"' failed.
Let's make it pass.
It should fail because
to_roman still always
returns "I"
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
std::cout << "All tests passed"
<< std::endl;
}
test_2_is_II();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
error: control reaches end of non-void function
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
error: control reaches end of non-void function
Eh?
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
error: control reaches end of non-void function
Eh?
Ah! It's saying that if
number doesn't equal one
or two then there is no
return statement.
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
error: control reaches end of non-void function
Eh?
Exactly.
Ah! It's saying that if
number doesn't equal one
or two then there is no
return statement.
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
How about this?
Try it!
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
error: control reaches end of non-void function
Eh?
Exactly.
That's easy to fix.
Ah! It's saying that if
number doesn't equal one
or two then there is no
return statement.
#include "to_roman.hpp"
std::string to_roman(int number)
{
return "I";
}
if (number == 1)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
}
if (number == 2)
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
}
return "II";
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
How about this?
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
Now another test.
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
How about this?
Looks good.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
Now another test.
ok
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
if (number == 1)
return "I";
if (number == 2)
return "II";
}
std::string roman = "";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
if (number == 2)
return "II";
}
roman = "I";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
}
roman = "II";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
}
return roman;
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
$ cc -Wall -Werror *.cpp && ./a.out
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
void test_3_is_III(): Assertion `to_roman(3) ==
"III"' failed.
..Aborted
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
void test_3_is_III(): Assertion `to_roman(3) ==
"III"' failed.
..Aborted
Now I'll make it pass.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
I'll add a test for
3 being III.That should fail.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
void test_3_is_III(): Assertion `to_roman(3) ==
"III"' failed.
..Aborted
Now I'll make it pass.
ok
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
std::cout << "All tests passed"
<< std::endl;
}
test_3_is_III();
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
Aha...
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
Aha...
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
Aha...
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
Aha...
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
Now another test.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
How about this?
Aha...
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
Yessss.
Now another test.
Hmmmm.....
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
return roman;
}
if (number == 3)
roman = "III";
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
Are you thinking we should
refactor first?
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
Are you thinking we should
refactor first?
Yes.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
Are you thinking we should
refactor first?
Yes.
I'd start with
the tests.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
What about the tests?
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
What about the tests?
The name of each test
repeats its body. In this
case the test name adds
nothing. How about
collapsing them all into a
single test.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
What about the tests?
The name of each test
repeats its body. In this
case the test name adds
nothing. How about
collapsing them all into a
single test.
Can you
show me?
How about this.
...
static void test_1_is_I()
{
assert(to_roman(1) == "I");
}
static void test_2_is_II()
{
assert(to_roman(2) == "II");
}
static void test_3_is_III()
{
assert(to_roman(3) == "III");
}
int main()
{
test_1_is_I();
test_2_is_II();
test_3_is_III();
std::cout << "All tests passed"
<< std::endl;
}
How about this.
...
static void test_to_roman()
{
assert(to_roman(1) == "I");
assert(to_roman(2) == "II");
assert(to_roman(3) == "III");
}
int main()
{
test_to_roman();
std::cout << "All tests passed"
<< std::endl;
}
How about this.
$ cc -Wall -Werror *.cpp && ./a.out
...
static void test_to_roman()
{
assert(to_roman(1) == "I");
assert(to_roman(2) == "II");
assert(to_roman(3) == "III");
}
int main()
{
test_to_roman();
std::cout << "All tests passed"
<< std::endl;
}
How about this.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
...
static void test_to_roman()
{
assert(to_roman(1) == "I");
assert(to_roman(2) == "II");
assert(to_roman(3) == "III");
}
int main()
{
test_to_roman();
std::cout << "All tests passed"
<< std::endl;
}
How about this.
Everything still passes.
$ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out
All tests passed
...
static void test_to_roman()
{
assert(to_roman(1) == "I");
assert(to_roman(2) == "II");
assert(to_roman(3) == "III");
}
int main()
{
test_to_roman();
std::cout << "All tests passed"
<< std::endl;
}
Next I'd refactor the code.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
Next I'd refactor the code.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
Yeah. An endless sequence
of if statements isn't going to
be much of a solution.
Next I'd refactor the code.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
Yeah. An endless sequence
of if statements isn't going to
be much of a solution.
Can I show you something neat?
Next I'd refactor the code.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
Yeah. An endless sequence
of if statements isn't going to
be much of a solution.
Can I show you something neat?
Sure
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman += "I";
return roman;
}
First I'll refactor the code so that each
if statement concatenates a single I.
$ cc -Wall -Werror *.cpp && ./a.out
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number == 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman = "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number == 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "II";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman = "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number == 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "III";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "II";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman = "I";
return roman;
}
#include "to_roman.hpp"
std::string to_roman(int number)
{
std::string roman = "";
if (number >= 1)
roman += "I";
if (number >= 2)
roman += "I";
if (number >= 3)
roman += "I";
return roman;
}
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++
Larry and Jen do Roman Numerals in C++

More Related Content

What's hot

IOT in Agriculture slide.pptx
IOT in Agriculture slide.pptxIOT in Agriculture slide.pptx
IOT in Agriculture slide.pptxDHANPDGHALE
 
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...Codemotion
 
AUGMENTED REALITY PPT's
AUGMENTED REALITY PPT'sAUGMENTED REALITY PPT's
AUGMENTED REALITY PPT'sVenu Gopal
 
170810 001 maintenance management procedure v2.1
170810 001 maintenance management procedure v2.1170810 001 maintenance management procedure v2.1
170810 001 maintenance management procedure v2.1Garry Pepper
 
Hardware Acceleration in WebKit
Hardware Acceleration in WebKitHardware Acceleration in WebKit
Hardware Acceleration in WebKitJoone Hur
 
Developing and validating statistical models for clinical prediction and prog...
Developing and validating statistical models for clinical prediction and prog...Developing and validating statistical models for clinical prediction and prog...
Developing and validating statistical models for clinical prediction and prog...Evangelos Kritsotakis
 
Reperes Metaverse Roadmap 290807 Gb
Reperes Metaverse Roadmap 290807 GbReperes Metaverse Roadmap 290807 Gb
Reperes Metaverse Roadmap 290807 GbFrançois Abiven
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with UnityMark Billinghurst
 
2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR SystemsMark Billinghurst
 
Web servers for the Internet of Things
Web servers for the Internet of ThingsWeb servers for the Internet of Things
Web servers for the Internet of ThingsAlexandru Radovici
 
Seminar report on augmented and virtual reality
Seminar report on augmented and virtual realitySeminar report on augmented and virtual reality
Seminar report on augmented and virtual realityDheeraj Chauhan
 
Quantum Computing - Basic Concepts
Quantum Computing - Basic ConceptsQuantum Computing - Basic Concepts
Quantum Computing - Basic ConceptsSendash Pangambam
 
Artifical Intelligence
Artifical IntelligenceArtifical Intelligence
Artifical IntelligenceHarsha Varyani
 
Augmented Reality Presentation
Augmented Reality PresentationAugmented Reality Presentation
Augmented Reality PresentationSJSU
 

What's hot (20)

Lecture 09: SLAM
Lecture 09: SLAMLecture 09: SLAM
Lecture 09: SLAM
 
IOT in Agriculture slide.pptx
IOT in Agriculture slide.pptxIOT in Agriculture slide.pptx
IOT in Agriculture slide.pptx
 
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...
WebXR: Introducing Mixed Reality and the Immersive Web - Peter O'Shaughnessy ...
 
AUGMENTED REALITY PPT's
AUGMENTED REALITY PPT'sAUGMENTED REALITY PPT's
AUGMENTED REALITY PPT's
 
170810 001 maintenance management procedure v2.1
170810 001 maintenance management procedure v2.1170810 001 maintenance management procedure v2.1
170810 001 maintenance management procedure v2.1
 
Hardware Acceleration in WebKit
Hardware Acceleration in WebKitHardware Acceleration in WebKit
Hardware Acceleration in WebKit
 
IOT BASED SMART AGRICULTURE
IOT BASED SMART AGRICULTUREIOT BASED SMART AGRICULTURE
IOT BASED SMART AGRICULTURE
 
Developing and validating statistical models for clinical prediction and prog...
Developing and validating statistical models for clinical prediction and prog...Developing and validating statistical models for clinical prediction and prog...
Developing and validating statistical models for clinical prediction and prog...
 
Reperes Metaverse Roadmap 290807 Gb
Reperes Metaverse Roadmap 290807 GbReperes Metaverse Roadmap 290807 Gb
Reperes Metaverse Roadmap 290807 Gb
 
IoT ecosystem
IoT ecosystemIoT ecosystem
IoT ecosystem
 
ReactPHP + Symfony
ReactPHP + SymfonyReactPHP + Symfony
ReactPHP + Symfony
 
Developing VR Experiences with Unity
Developing VR Experiences with UnityDeveloping VR Experiences with Unity
Developing VR Experiences with Unity
 
2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems2022 COMP4010 Lecture 6: Designing AR Systems
2022 COMP4010 Lecture 6: Designing AR Systems
 
Web servers for the Internet of Things
Web servers for the Internet of ThingsWeb servers for the Internet of Things
Web servers for the Internet of Things
 
Lecture 4: VR Systems
Lecture 4: VR SystemsLecture 4: VR Systems
Lecture 4: VR Systems
 
Seminar report on augmented and virtual reality
Seminar report on augmented and virtual realitySeminar report on augmented and virtual reality
Seminar report on augmented and virtual reality
 
Quantum Computing - Basic Concepts
Quantum Computing - Basic ConceptsQuantum Computing - Basic Concepts
Quantum Computing - Basic Concepts
 
Artifical Intelligence
Artifical IntelligenceArtifical Intelligence
Artifical Intelligence
 
Quantum computers
Quantum computersQuantum computers
Quantum computers
 
Augmented Reality Presentation
Augmented Reality PresentationAugmented Reality Presentation
Augmented Reality Presentation
 

Viewers also liked

lessons from testing
lessons from testinglessons from testing
lessons from testingJon Jagger
 
Atlantec - tdd lessons
Atlantec - tdd lessonsAtlantec - tdd lessons
Atlantec - tdd lessonsJon Jagger
 
Year 4 equivalent fractions
Year 4 equivalent fractionsYear 4 equivalent fractions
Year 4 equivalent fractionsQwizdom UK
 
The dog ate my homework
The dog ate my homeworkThe dog ate my homework
The dog ate my homeworkHeworthMedia1
 
Best ppt on solar system
Best ppt on solar systemBest ppt on solar system
Best ppt on solar systemMake Megenius
 
Literacy Reimagined
Literacy Reimagined Literacy Reimagined
Literacy Reimagined Angela Maiers
 
Solar System
Solar SystemSolar System
Solar Systemgoogle
 
The Solar System Powerpoint
The Solar System PowerpointThe Solar System Powerpoint
The Solar System Powerpointoliverh
 
Guided Reading: Making the Most of It
Guided Reading: Making the Most of ItGuided Reading: Making the Most of It
Guided Reading: Making the Most of ItJennifer Jones
 

Viewers also liked (13)

lessons from testing
lessons from testinglessons from testing
lessons from testing
 
Deep C
Deep CDeep C
Deep C
 
Atlantec - tdd lessons
Atlantec - tdd lessonsAtlantec - tdd lessons
Atlantec - tdd lessons
 
Roman numerals cc
Roman numerals ccRoman numerals cc
Roman numerals cc
 
Year 4 equivalent fractions
Year 4 equivalent fractionsYear 4 equivalent fractions
Year 4 equivalent fractions
 
The dog ate my homework
The dog ate my homeworkThe dog ate my homework
The dog ate my homework
 
Best ppt on solar system
Best ppt on solar systemBest ppt on solar system
Best ppt on solar system
 
Literacy Reimagined
Literacy Reimagined Literacy Reimagined
Literacy Reimagined
 
Solar System
Solar SystemSolar System
Solar System
 
Solar System Facts Slideshow
Solar System Facts SlideshowSolar System Facts Slideshow
Solar System Facts Slideshow
 
Solar System Ppt
Solar System PptSolar System Ppt
Solar System Ppt
 
The Solar System Powerpoint
The Solar System PowerpointThe Solar System Powerpoint
The Solar System Powerpoint
 
Guided Reading: Making the Most of It
Guided Reading: Making the Most of ItGuided Reading: Making the Most of It
Guided Reading: Making the Most of It
 

Similar to Larry and Jen do Roman Numerals in C++

Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFTimur Safin
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++Neeru Mittal
 
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.8 book - Part 29 of 202The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.8 book - Part 29 of 202Mahmoud Samir Fayed
 
I made the code below- however I have a problem in the test code like.docx
I made the code below- however I have a problem in the test code like.docxI made the code below- however I have a problem in the test code like.docx
I made the code below- however I have a problem in the test code like.docxcwayne3
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189Mahmoud Samir Fayed
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
The Ring programming language version 1.2 book - Part 14 of 84
The Ring programming language version 1.2 book - Part 14 of 84The Ring programming language version 1.2 book - Part 14 of 84
The Ring programming language version 1.2 book - Part 14 of 84Mahmoud Samir Fayed
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadiesAlicia Pérez
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyGrejoJoby1
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 
Python tutorial
Python tutorialPython tutorial
Python tutorialRajiv Risi
 
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189Mahmoud Samir Fayed
 

Similar to Larry and Jen do Roman Numerals in C++ (20)

Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
Intro to ruby
Intro to rubyIntro to ruby
Intro to ruby
 
Library functions in c++
Library functions in c++Library functions in c++
Library functions in c++
 
The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184The Ring programming language version 1.5.3 book - Part 24 of 184
The Ring programming language version 1.5.3 book - Part 24 of 184
 
The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210The Ring programming language version 1.9 book - Part 31 of 210
The Ring programming language version 1.9 book - Part 31 of 210
 
The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.8 book - Part 29 of 202The Ring programming language version 1.8 book - Part 29 of 202
The Ring programming language version 1.8 book - Part 29 of 202
 
Cpp programs
Cpp programsCpp programs
Cpp programs
 
DataTypes.ppt
DataTypes.pptDataTypes.ppt
DataTypes.ppt
 
I made the code below- however I have a problem in the test code like.docx
I made the code below- however I have a problem in the test code like.docxI made the code below- however I have a problem in the test code like.docx
I made the code below- however I have a problem in the test code like.docx
 
The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189The Ring programming language version 1.6 book - Part 26 of 189
The Ring programming language version 1.6 book - Part 26 of 189
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
The Ring programming language version 1.2 book - Part 14 of 84
The Ring programming language version 1.2 book - Part 14 of 84The Ring programming language version 1.2 book - Part 14 of 84
The Ring programming language version 1.2 book - Part 14 of 84
 
String
StringString
String
 
Beautiful python - PyLadies
Beautiful python - PyLadiesBeautiful python - PyLadies
Beautiful python - PyLadies
 
P2 2017 python_strings
P2 2017 python_stringsP2 2017 python_strings
P2 2017 python_strings
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185The Ring programming language version 1.5.4 book - Part 24 of 185
The Ring programming language version 1.5.4 book - Part 24 of 185
 
The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189The Ring programming language version 1.6 book - Part 183 of 189
The Ring programming language version 1.6 book - Part 183 of 189
 

More from Jon Jagger

Design and Evolution of cyber-dojo
Design and Evolution of cyber-dojoDesign and Evolution of cyber-dojo
Design and Evolution of cyber-dojoJon Jagger
 
NorDevCon 2016 pair programming
NorDevCon 2016 pair programmingNorDevCon 2016 pair programming
NorDevCon 2016 pair programmingJon Jagger
 
Oslo Day of Docker Opening Keynote
Oslo Day of Docker Opening KeynoteOslo Day of Docker Opening Keynote
Oslo Day of Docker Opening KeynoteJon Jagger
 
Pair programming
Pair programmingPair programming
Pair programmingJon Jagger
 
Cyber-dojo: How to perform deliberate practice
Cyber-dojo: How to perform deliberate practiceCyber-dojo: How to perform deliberate practice
Cyber-dojo: How to perform deliberate practiceJon Jagger
 
Lessons from Testing
Lessons from TestingLessons from Testing
Lessons from TestingJon Jagger
 
Systems thinking
Systems thinkingSystems thinking
Systems thinkingJon Jagger
 
Kanban Push-me Pull-you
Kanban Push-me Pull-youKanban Push-me Pull-you
Kanban Push-me Pull-youJon Jagger
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and developmentJon Jagger
 
Systems Thinking
Systems ThinkingSystems Thinking
Systems ThinkingJon Jagger
 
An Agile A to Z
An Agile A to ZAn Agile A to Z
An Agile A to ZJon Jagger
 

More from Jon Jagger (11)

Design and Evolution of cyber-dojo
Design and Evolution of cyber-dojoDesign and Evolution of cyber-dojo
Design and Evolution of cyber-dojo
 
NorDevCon 2016 pair programming
NorDevCon 2016 pair programmingNorDevCon 2016 pair programming
NorDevCon 2016 pair programming
 
Oslo Day of Docker Opening Keynote
Oslo Day of Docker Opening KeynoteOslo Day of Docker Opening Keynote
Oslo Day of Docker Opening Keynote
 
Pair programming
Pair programmingPair programming
Pair programming
 
Cyber-dojo: How to perform deliberate practice
Cyber-dojo: How to perform deliberate practiceCyber-dojo: How to perform deliberate practice
Cyber-dojo: How to perform deliberate practice
 
Lessons from Testing
Lessons from TestingLessons from Testing
Lessons from Testing
 
Systems thinking
Systems thinkingSystems thinking
Systems thinking
 
Kanban Push-me Pull-you
Kanban Push-me Pull-youKanban Push-me Pull-you
Kanban Push-me Pull-you
 
Some stuff about C++ and development
Some stuff about C++ and developmentSome stuff about C++ and development
Some stuff about C++ and development
 
Systems Thinking
Systems ThinkingSystems Thinking
Systems Thinking
 
An Agile A to Z
An Agile A to ZAn Agile A to Z
An Agile A to Z
 

Recently uploaded

Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxUdaiappa Ramachandran
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...Aggregage
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfDaniel Santiago Silva Capera
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxGDSC PJATK
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7DianaGray10
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 

Recently uploaded (20)

Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
20150722 - AGV
20150722 - AGV20150722 - AGV
20150722 - AGV
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Building AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptxBuilding AI-Driven Apps Using Semantic Kernel.pptx
Building AI-Driven Apps Using Semantic Kernel.pptx
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
The Data Metaverse: Unpacking the Roles, Use Cases, and Tech Trends in Data a...
 
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdfIaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
IaC & GitOps in a Nutshell - a FridayInANuthshell Episode.pdf
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
Cybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptxCybersecurity Workshop #1.pptx
Cybersecurity Workshop #1.pptx
 
UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7UiPath Studio Web workshop series - Day 7
UiPath Studio Web workshop series - Day 7
 
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 

Larry and Jen do Roman Numerals in C++

  • 1. Larry and Jen do Roman Numerals in C++ by Jon Jagger and Olve Maudal http://www.slideshare.net/olvemaudal/deep-c Larry and Jen first appeared in the popular Deep C (and C++) presentation
  • 2. Jen, will you help me do some C++ practice?
  • 3. Jen, will you help me do some C++ practice? Sure Larry.
  • 4. Given a positive integer number (eg 42) determine its Roman numeral representation as a String (eg "XLII"). The Roman 'letters' are: 1 -> "I" | 10 -> "X" | 100 -> "C" | 1000 -> "M" 2 -> "II" | 20 -> "XX" | 200 -> "CC" | 2000 -> "MM" 3 -> "III" | 30 -> "XXX" | 300 -> "CCC" | 3000 -> "MMM" 4 -> "IV" | 40 -> "XL" | 400 -> "CD" | 4000 -> "MMMM" 5 -> "V" | 50 -> "L" | 500 -> "D" 6 -> "VI" | 60 -> "LX" | 600 -> "DC" 7 -> "VII" | 70 -> "LXX" | 700 -> "DCC" 8 -> "VIII" | 80 -> "LXXX" | 800 -> "DCCC" 9 -> "IX" | 90 -> "XC" | 900 -> "CM" You cannot write numerals like IM for 999. Wikipedia states "Modern Roman numerals are written by expressing each digit separately starting with the leftmost digit and skipping any digit with a value of zero." Examples: o) 1990 -> "MCMXC" (1000 -> "M" + 900 -> "CM" + 90 -> "XC") o) 2008 -> "MMVIII" (2000 -> "MM" + 8 -> "VIII") o) 99 -> "XCIX" ( 90 -> "XC" + 9 -> "IX") o) 47 -> "XLVII" ( 40 -> "XL" + 7 -> "VII") How about the roman numerals kata?
  • 5. Given a positive integer number (eg 42) determine its Roman numeral representation as a String (eg "XLII"). The Roman 'letters' are: 1 -> "I" | 10 -> "X" | 100 -> "C" | 1000 -> "M" 2 -> "II" | 20 -> "XX" | 200 -> "CC" | 2000 -> "MM" 3 -> "III" | 30 -> "XXX" | 300 -> "CCC" | 3000 -> "MMM" 4 -> "IV" | 40 -> "XL" | 400 -> "CD" | 4000 -> "MMMM" 5 -> "V" | 50 -> "L" | 500 -> "D" 6 -> "VI" | 60 -> "LX" | 600 -> "DC" 7 -> "VII" | 70 -> "LXX" | 700 -> "DCC" 8 -> "VIII" | 80 -> "LXXX" | 800 -> "DCCC" 9 -> "IX" | 90 -> "XC" | 900 -> "CM" You cannot write numerals like IM for 999. Wikipedia states "Modern Roman numerals are written by expressing each digit separately starting with the leftmost digit and skipping any digit with a value of zero." Examples: o) 1990 -> "MCMXC" (1000 -> "M" + 900 -> "CM" + 90 -> "XC") o) 2008 -> "MMVIII" (2000 -> "MM" + 8 -> "VIII") o) 99 -> "XCIX" ( 90 -> "XC" + 9 -> "IX") o) 47 -> "XLVII" ( 40 -> "XL" + 7 -> "VII") How about the roman numerals kata? ok
  • 6. #include "to_roman.hpp" #include <cassert> #include <iostream> int main() { std::cout << "All tests passed" << std::endl; } to_roman.tests.cpp I'll start with a test. 1 should be I.
  • 7. #include "to_roman.hpp" #include <cassert> #include <iostream> int main() { std::cout << "All tests passed" << std::endl; } to_roman.tests.cpp I'll start with a test. 1 should be I.#include "to_roman.hpp" #include <cassert> #include <iostream> int main() { std::cout << "All tests passed" << std::endl; }
  • 8. #include "to_roman.hpp" #include <cassert> #include <iostream> int main() { std::cout << "All tests passed" << std::endl; } to_roman.tests.cpp I'll start with a test. 1 should be I.#include "to_roman.hpp" #include <cassert> #include <iostream> int main() { std::cout << "All tests passed" << std::endl; } static void test_1_is_I() { assert(to_roman(1) == "I"); }
  • 9. Here's my header file, to_roman.hpp
  • 10. #ifndef TO_ROMAN_INCLUDED #define TO_ROMAN_INCLUDED #include <string> std::string to_roman(int number); #endif Here's my header file, to_roman.hpp
  • 11. #ifndef TO_ROMAN_INCLUDED #define TO_ROMAN_INCLUDED #include <string> std::string to_roman(int number); #endif Here's my header file, to_roman.hpp Here's my source file, to_roman.cpp
  • 12. #ifndef TO_ROMAN_INCLUDED #define TO_ROMAN_INCLUDED #include <string> std::string to_roman(int number); #endif Here's my header file, to_roman.hpp Here's my source file, to_roman.cpp #include "to_roman.hpp" std::string to_roman(int number) { return ""; }
  • 13. #ifndef TO_ROMAN_INCLUDED #define TO_ROMAN_INCLUDED #include <string> std::string to_roman(int number); #endif Here's my header file, to_roman.hpp ok Here's my source file, to_roman.cpp #include "to_roman.hpp" std::string to_roman(int number) { return ""; }
  • 14. How are you building and running?
  • 15. How are you building and running? With this.
  • 16. How are you building and running? $ cc *.cpp && ./a.out With this.
  • 17. How are you building and running? $ cc *.cpp && ./a.out With this. Try it.
  • 18. How are you building and running? $ cc *.cpp && ./a.out With this. Try it. $ cc *.cpp && ./a.out All tests passed
  • 19. How are you building and running? $ cc *.cpp && ./a.out With this. Try it. $ cc *.cpp && ./a.out All tests passed Eh? That's not right. It should have failed!
  • 20. How are you building and running? $ cc *.cpp && ./a.out With this. Try it. $ cc *.cpp && ./a.out All tests passed Eh? That's not right. It should have failed! Let's see the tests again.
  • 21. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm.
  • 22. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm.
  • 23. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. That's easy to fix.
  • 24. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. That's easy to fix. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; }
  • 25. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. That's easy to fix. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } test_1_is_I();
  • 26. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. $ cc *.cpp && ./a.out That's easy to fix. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } test_1_is_I();
  • 27. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. $ cc *.cpp && ./a.out$ cc *.cpp && ./a.out Assertion failed: (to_roman(1) == "I") That's easy to fix. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } test_1_is_I();
  • 28. Of course.We're not calling the test! #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } Hmmmm. $ cc *.cpp && ./a.out$ cc *.cpp && ./a.out Assertion failed: (to_roman(1) == "I") That's easy to fix. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { std::cout << "All tests passed" << std::endl; } test_1_is_I(); Now it fails.
  • 29. I can simply change the the return value to make it pass. #include "to_roman.hpp" std::string to_roman(int number) { return ""; }
  • 30. I can simply change the the return value to make it pass. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; }
  • 31. I can simply change the the return value to make it pass. $ cc *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { return "I"; }
  • 32. I can simply change the the return value to make it pass. $ cc *.cpp && ./a.out$ cc *.cpp && ./a.out All tests passed #include "to_roman.hpp" std::string to_roman(int number) { return "I"; }
  • 33. I can simply change the the return value to make it pass. $ cc *.cpp && ./a.out$ cc *.cpp && ./a.out All tests passed ok #include "to_roman.hpp" std::string to_roman(int number) { return "I"; }
  • 34. Let's write another test. 2 should be II
  • 35. I think there is a problem we should fix first. Let's write another test. 2 should be II
  • 36. I think there is a problem we should fix first. Let's write another test. 2 should be II What problem?
  • 37. I think there is a problem we should fix first. Let's write another test. 2 should be II What problem? We've fixed the immediate issue by calling the function. But what happens the next time we forget?
  • 38. I think there is a problem we should fix first. Let's write another test. 2 should be II What problem? We've fixed the immediate issue by calling the function. But what happens the next time we forget? What do you suggest?
  • 39. Could the compiler detect when we have a function that is defined but not used?
  • 40. Could the compiler detect when we have a function that is defined but not used? A command line option?
  • 41. Yes. It's one of the smells the compiler can detect with the -Wall flag. Could the compiler detect when we have a function that is defined but not used? A command line option?
  • 42. Yes. It's one of the smells the compiler can detect with the -Wall flag. ok. Let me try that. Could the compiler detect when we have a function that is defined but not used? A command line option?
  • 43. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call
  • 44. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 45. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 46. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call and add the -Wall flag #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 47. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call $ cc *.cpp && ./a.out and add the -Wall flag #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 48. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call $ cc *.cpp && ./a.out and add the -Wall flag $ cc *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 49. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call $ cc *.cpp && ./a.out and add the -Wall flag $ cc *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } -Wall
  • 50. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call $ cc *.cpp && ./a.out and add the -Wall flag $ cc *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } -Wall$ cc -Wall *.cpp && ./a.out warning: 'void test_1_is_I()' is defined but not used All tests passed
  • 51. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll comment out the call $ cc *.cpp && ./a.out and add the -Wall flag $ cc *.cpp && ./a.out now I get the warning #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } -Wall$ cc -Wall *.cpp && ./a.out warning: 'void test_1_is_I()' is defined but not used All tests passed
  • 52. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } Turning the warning into an error would be even better. We can do that with the -Werror flag
  • 53. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } Turning the warning into an error would be even better. We can do that with the -Werror flag Agreed.
  • 54. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall *.cpp && ./a.out Turning the warning into an error would be even better. We can do that with the -Werror flag Agreed.
  • 55. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall *.cpp && ./a.out Turning the warning into an error would be even better. We can do that with the -Werror flag $ cc -Wall *.cpp && ./a.out Agreed.
  • 56. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall *.cpp && ./a.out Turning the warning into an error would be even better. We can do that with the -Werror flag $ cc -Wall *.cpp && ./a.out-Werror Agreed.
  • 57. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall *.cpp && ./a.out Turning the warning into an error would be even better. We can do that with the -Werror flag $ cc -Wall *.cpp && ./a.out-Werror$ cc -Wall -Werror *.cpp && ./a.out error: 'void test_1_is_I()' is defined but not used Agreed.
  • 58. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again.
  • 59. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 60. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 61. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again. $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 62. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again. $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall -Werror *.cpp && ./a.out All tests passed
  • 63. #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { //test_1_is_I(); std::cout << "All tests passed" << std::endl; } I'll uncomment the comment so the test passes again. Now we can write the next test. $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { /test_1_is_I(); std::cout << "All tests passed" << std::endl; } #include "to_roman.hpp" #include <cassert> #include <iostream> static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } $ cc -Wall -Werror *.cpp && ./a.out All tests passed
  • 64. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II
  • 65. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; }
  • 66. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II();
  • 67. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; }
  • 68. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } static void test_2_is_II() { assert(to_roman(2) == "II"); }
  • 69. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II It should fail because to_roman still always returns "I" ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } static void test_2_is_II() { assert(to_roman(2) == "II"); }
  • 70. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II $ cc -Wall -Werror *.cpp && ./a.out It should fail because to_roman still always returns "I" ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } static void test_2_is_II() { assert(to_roman(2) == "II"); }
  • 71. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out void test_2_is_II(): Assertion `to_roman(2) == "II"' failed. It should fail because to_roman still always returns "I" ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } static void test_2_is_II() { assert(to_roman(2) == "II"); }
  • 72. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } 2 should be II $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out void test_2_is_II(): Assertion `to_roman(2) == "II"' failed. Let's make it pass. It should fail because to_roman still always returns "I" ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); std::cout << "All tests passed" << std::endl; } test_2_is_II(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } static void test_2_is_II() { assert(to_roman(2) == "II"); }
  • 73. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this?
  • 74. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; }
  • 75. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1)
  • 76. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; }
  • 77. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; }
  • 78. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2)
  • 79. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) }
  • 80. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 81. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 82. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 83. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out error: control reaches end of non-void function #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 84. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out error: control reaches end of non-void function Eh? #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 85. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out error: control reaches end of non-void function Eh? Ah! It's saying that if number doesn't equal one or two then there is no return statement. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 86. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out error: control reaches end of non-void function Eh? Exactly. Ah! It's saying that if number doesn't equal one or two then there is no return statement. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 87. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } How about this? Try it! $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out error: control reaches end of non-void function Eh? Exactly. That's easy to fix. Ah! It's saying that if number doesn't equal one or two then there is no return statement. #include "to_roman.hpp" std::string to_roman(int number) { return "I"; } if (number == 1) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; } if (number == 2) #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) } return "II";
  • 88. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; }
  • 89. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; }
  • 90. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = "";
  • 91. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; }
  • 92. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I";
  • 93. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) }
  • 94. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II";
  • 95. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; }
  • 96. How about this? #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 97. How about this? Looks good. #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 98. How about this? Looks good. $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 99. How about this? Looks good. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 100. How about this? Looks good. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 101. How about this? Looks good. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. Now another test. #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 102. How about this? Looks good. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. Now another test. ok #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } #include "to_roman.hpp" std::string to_roman(int number) { if (number == 1) return "I"; if (number == 2) return "II"; } std::string roman = ""; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) if (number == 2) return "II"; } roman = "I"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) } roman = "II"; #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; } return roman;
  • 103. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail.
  • 104. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; }
  • 105. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III();
  • 106. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; }
  • 107. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } static void test_3_is_III() { assert(to_roman(3) == "III"); }
  • 108. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. $ cc -Wall -Werror *.cpp && ./a.out ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } static void test_3_is_III() { assert(to_roman(3) == "III"); }
  • 109. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out void test_3_is_III(): Assertion `to_roman(3) == "III"' failed. ..Aborted ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } static void test_3_is_III() { assert(to_roman(3) == "III"); }
  • 110. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out void test_3_is_III(): Assertion `to_roman(3) == "III"' failed. ..Aborted Now I'll make it pass. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } static void test_3_is_III() { assert(to_roman(3) == "III"); }
  • 111. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } I'll add a test for 3 being III.That should fail. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out void test_3_is_III(): Assertion `to_roman(3) == "III"' failed. ..Aborted Now I'll make it pass. ok ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); std::cout << "All tests passed" << std::endl; } test_3_is_III(); ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } static void test_3_is_III() { assert(to_roman(3) == "III"); }
  • 112. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? $ cc -Wall -Werror *.cpp && ./a.out
  • 113. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; }
  • 114. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 115. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? Aha... $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 116. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? Aha... $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 117. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? Aha... $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 118. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? Aha... $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. Now another test. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 119. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } How about this? Aha... $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed Yessss. Now another test. Hmmmm..... #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; return roman; } if (number == 3) roman = "III";
  • 120. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } Are you thinking we should refactor first?
  • 121. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } Are you thinking we should refactor first? Yes.
  • 122. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } Are you thinking we should refactor first? Yes. I'd start with the tests.
  • 123. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } What about the tests?
  • 124. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } What about the tests? The name of each test repeats its body. In this case the test name adds nothing. How about collapsing them all into a single test.
  • 125. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; } What about the tests? The name of each test repeats its body. In this case the test name adds nothing. How about collapsing them all into a single test. Can you show me?
  • 126. How about this. ... static void test_1_is_I() { assert(to_roman(1) == "I"); } static void test_2_is_II() { assert(to_roman(2) == "II"); } static void test_3_is_III() { assert(to_roman(3) == "III"); } int main() { test_1_is_I(); test_2_is_II(); test_3_is_III(); std::cout << "All tests passed" << std::endl; }
  • 127. How about this. ... static void test_to_roman() { assert(to_roman(1) == "I"); assert(to_roman(2) == "II"); assert(to_roman(3) == "III"); } int main() { test_to_roman(); std::cout << "All tests passed" << std::endl; }
  • 128. How about this. $ cc -Wall -Werror *.cpp && ./a.out ... static void test_to_roman() { assert(to_roman(1) == "I"); assert(to_roman(2) == "II"); assert(to_roman(3) == "III"); } int main() { test_to_roman(); std::cout << "All tests passed" << std::endl; }
  • 129. How about this. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed ... static void test_to_roman() { assert(to_roman(1) == "I"); assert(to_roman(2) == "II"); assert(to_roman(3) == "III"); } int main() { test_to_roman(); std::cout << "All tests passed" << std::endl; }
  • 130. How about this. Everything still passes. $ cc -Wall -Werror *.cpp && ./a.out$ cc -Wall -Werror *.cpp && ./a.out All tests passed ... static void test_to_roman() { assert(to_roman(1) == "I"); assert(to_roman(2) == "II"); assert(to_roman(3) == "III"); } int main() { test_to_roman(); std::cout << "All tests passed" << std::endl; }
  • 131. Next I'd refactor the code. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; }
  • 132. Next I'd refactor the code. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } Yeah. An endless sequence of if statements isn't going to be much of a solution.
  • 133. Next I'd refactor the code. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } Yeah. An endless sequence of if statements isn't going to be much of a solution. Can I show you something neat?
  • 134. Next I'd refactor the code. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } Yeah. An endless sequence of if statements isn't going to be much of a solution. Can I show you something neat? Sure
  • 135. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; }
  • 136. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; }
  • 137. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; }
  • 138. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; }
  • 139. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; }
  • 140. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; }
  • 141. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; }
  • 142. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; }
  • 143. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; }
  • 144. First I'll refactor the code so that each if statement concatenates a single I. #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman += "I"; return roman; }
  • 145. First I'll refactor the code so that each if statement concatenates a single I. $ cc -Wall -Werror *.cpp && ./a.out #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number == 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman = "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number == 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "II"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman = "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number == 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "III"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "II"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman = "I"; return roman; } #include "to_roman.hpp" std::string to_roman(int number) { std::string roman = ""; if (number >= 1) roman += "I"; if (number >= 2) roman += "I"; if (number >= 3) roman += "I"; return roman; }