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

Real-time Object Detection with YOLO v5, Hands-on-Lab
Real-time Object Detection with YOLO v5, Hands-on-LabReal-time Object Detection with YOLO v5, Hands-on-Lab
Real-time Object Detection with YOLO v5, Hands-on-LabJongHyunKim78
 
Mobile AR Lecture6 - Introduction to Unity 3D
Mobile AR Lecture6 - Introduction to Unity 3DMobile AR Lecture6 - Introduction to Unity 3D
Mobile AR Lecture6 - Introduction to Unity 3DMark Billinghurst
 
AI勉強会用スライド
AI勉強会用スライドAI勉強会用スライド
AI勉強会用スライドharmonylab
 
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인강 민우
 
GDC 2014 - Deformable Snow Rendering in Batman: Arkham Origins
GDC 2014 - Deformable Snow Rendering in Batman: Arkham OriginsGDC 2014 - Deformable Snow Rendering in Batman: Arkham Origins
GDC 2014 - Deformable Snow Rendering in Batman: Arkham OriginsColin Barré-Brisebois
 
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법장규 서
 
HDR Theory and practicce (JP)
HDR Theory and practicce (JP)HDR Theory and practicce (JP)
HDR Theory and practicce (JP)Hajime Uchimura
 
文献紹介:Omnivore: A Single Model for Many Visual Modalities
文献紹介:Omnivore: A Single Model for Many Visual Modalities文献紹介:Omnivore: A Single Model for Many Visual Modalities
文献紹介:Omnivore: A Single Model for Many Visual ModalitiesToru Tamaki
 
RenderTextureの正しいα値は?
RenderTextureの正しいα値は?RenderTextureの正しいα値は?
RenderTextureの正しいα値は?KLab Inc. / Tech
 
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근Visual Tech Dev
 
장용석, fmod를이용한사운드프로그래밍, NDC2010
장용석, fmod를이용한사운드프로그래밍, NDC2010장용석, fmod를이용한사운드프로그래밍, NDC2010
장용석, fmod를이용한사운드프로그래밍, NDC2010devCAT Studio, NEXON
 
Rendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb RaiderRendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb RaiderEidos-Montréal
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity IntroductionJuwal Bose
 
ゲームAI製作のためのワークショップ(I)
ゲームAI製作のためのワークショップ(I)ゲームAI製作のためのワークショップ(I)
ゲームAI製作のためのワークショップ(I)Youichiro Miyake
 
Anomaly Detection with GANs
Anomaly Detection with GANsAnomaly Detection with GANs
Anomaly Detection with GANs홍배 김
 
ECS: Streaming and Serialization - Unite LA
ECS: Streaming and Serialization - Unite LAECS: Streaming and Serialization - Unite LA
ECS: Streaming and Serialization - Unite LAUnity Technologies
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019devCAT Studio, NEXON
 
UE4のレイトレで出来ること/出来ないこと
UE4のレイトレで出来ること/出来ないことUE4のレイトレで出来ること/出来ないこと
UE4のレイトレで出来ること/出来ないことSatoshi Kodaira
 
Building Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero DawnBuilding Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero DawnGuerrilla
 
A Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemBo Li
 

What's hot (20)

Real-time Object Detection with YOLO v5, Hands-on-Lab
Real-time Object Detection with YOLO v5, Hands-on-LabReal-time Object Detection with YOLO v5, Hands-on-Lab
Real-time Object Detection with YOLO v5, Hands-on-Lab
 
Mobile AR Lecture6 - Introduction to Unity 3D
Mobile AR Lecture6 - Introduction to Unity 3DMobile AR Lecture6 - Introduction to Unity 3D
Mobile AR Lecture6 - Introduction to Unity 3D
 
AI勉強会用スライド
AI勉強会用スライドAI勉強会用スライド
AI勉強会用スライド
 
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인
[IGC2018] 캡콤 토쿠다 유야 - 몬스터헌터 월드의 게임 컨셉과 레벨 디자인
 
GDC 2014 - Deformable Snow Rendering in Batman: Arkham Origins
GDC 2014 - Deformable Snow Rendering in Batman: Arkham OriginsGDC 2014 - Deformable Snow Rendering in Batman: Arkham Origins
GDC 2014 - Deformable Snow Rendering in Batman: Arkham Origins
 
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법Unite2019 HLOD를 활용한 대규모 씬 제작 방법
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
 
HDR Theory and practicce (JP)
HDR Theory and practicce (JP)HDR Theory and practicce (JP)
HDR Theory and practicce (JP)
 
文献紹介:Omnivore: A Single Model for Many Visual Modalities
文献紹介:Omnivore: A Single Model for Many Visual Modalities文献紹介:Omnivore: A Single Model for Many Visual Modalities
文献紹介:Omnivore: A Single Model for Many Visual Modalities
 
RenderTextureの正しいα値は?
RenderTextureの正しいα値は?RenderTextureの正しいα値は?
RenderTextureの正しいα値は?
 
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근
우리 프로젝트에 맞는 게임 엔진 - 테크니컬아트디렉터 김태근
 
장용석, fmod를이용한사운드프로그래밍, NDC2010
장용석, fmod를이용한사운드프로그래밍, NDC2010장용석, fmod를이용한사운드프로그래밍, NDC2010
장용석, fmod를이용한사운드프로그래밍, NDC2010
 
Rendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb RaiderRendering Techniques in Rise of the Tomb Raider
Rendering Techniques in Rise of the Tomb Raider
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
 
ゲームAI製作のためのワークショップ(I)
ゲームAI製作のためのワークショップ(I)ゲームAI製作のためのワークショップ(I)
ゲームAI製作のためのワークショップ(I)
 
Anomaly Detection with GANs
Anomaly Detection with GANsAnomaly Detection with GANs
Anomaly Detection with GANs
 
ECS: Streaming and Serialization - Unite LA
ECS: Streaming and Serialization - Unite LAECS: Streaming and Serialization - Unite LA
ECS: Streaming and Serialization - Unite LA
 
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
김혁, <드래곤 하운드>의 PBR과 레이트레이싱 렌더링 기법, NDC2019
 
UE4のレイトレで出来ること/出来ないこと
UE4のレイトレで出来ること/出来ないことUE4のレイトレで出来ること/出来ないこと
UE4のレイトレで出来ること/出来ないこと
 
Building Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero DawnBuilding Non-Linear Narratives in Horizon Zero Dawn
Building Non-Linear Narratives in Horizon Zero Dawn
 
A Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering SystemA Scalable Real-Time Many-Shadowed-Light Rendering System
A Scalable Real-Time Many-Shadowed-Light Rendering System
 

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
 
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
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfezonesolutions
 
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
 
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
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
 
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

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 

Recently uploaded (20)

Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 

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; }