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

Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻小林 信行
 
Androidの新ビルドシステム
Androidの新ビルドシステムAndroidの新ビルドシステム
Androidの新ビルドシステムl_b__
 
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法Yoshifumi Kawai
 
サイボウズのフロントエンド開発 現在とこれからの挑戦
サイボウズのフロントエンド開発 現在とこれからの挑戦サイボウズのフロントエンド開発 現在とこれからの挑戦
サイボウズのフロントエンド開発 現在とこれからの挑戦Teppei Sato
 
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメント
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメントCatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメント
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメントYoshiomi Kure
 
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術Unity Technologies Japan K.K.
 
テストを書こう、Unity編
テストを書こう、Unity編テストを書こう、Unity編
テストを書こう、Unity編Hiroto Imoto
 
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4浮動小数点(IEEE754)を圧縮したい@dsirnlp#4
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4Takeshi Yamamuro
 
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)Takashi Yoshinaga
 
【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現Unity Technologies Japan K.K.
 
Usb接続するアプリを開発した時に試行錯誤した事
Usb接続するアプリを開発した時に試行錯誤した事Usb接続するアプリを開発した時に試行錯誤した事
Usb接続するアプリを開発した時に試行錯誤した事Masataka Kono
 
CMake multiplatform build-tool
CMake multiplatform build-toolCMake multiplatform build-tool
CMake multiplatform build-toolNaruto TAKAHASHI
 
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならねUnity Technologies Japan K.K.
 
最近の単体テスト
最近の単体テスト最近の単体テスト
最近の単体テストKen Morishita
 
NuGetの社内利用のススメ
NuGetの社内利用のススメNuGetの社内利用のススメ
NuGetの社内利用のススメNarami Kiyokura
 
モバイル通信を使わない 近接端末間通信対戦のレシピ
モバイル通信を使わない 近接端末間通信対戦のレシピモバイル通信を使わない 近接端末間通信対戦のレシピ
モバイル通信を使わない 近接端末間通信対戦のレシピNakamuraTaro
 
UMLモデルを使った自動生成
UMLモデルを使った自動生成UMLモデルを使った自動生成
UMLモデルを使った自動生成Norihito Ohshima
 
iOSアプリ UIテスト自動化入門
iOSアプリ UIテスト自動化入門iOSアプリ UIテスト自動化入門
iOSアプリ UIテスト自動化入門Shingo Tamaki
 
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならねUnityTechnologiesJapan002
 

What's hot (20)

Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻Unity道場08「絵づくりの基礎」ライティング虎の巻
Unity道場08「絵づくりの基礎」ライティング虎の巻
 
Androidの新ビルドシステム
Androidの新ビルドシステムAndroidの新ビルドシステム
Androidの新ビルドシステム
 
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
 
サイボウズのフロントエンド開発 現在とこれからの挑戦
サイボウズのフロントエンド開発 現在とこれからの挑戦サイボウズのフロントエンド開発 現在とこれからの挑戦
サイボウズのフロントエンド開発 現在とこれからの挑戦
 
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメント
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメントCatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメント
CatchUp! 謎だらけのゲーム開発 vol.02 カラーマネージメント
 
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
 
テストを書こう、Unity編
テストを書こう、Unity編テストを書こう、Unity編
テストを書こう、Unity編
 
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4浮動小数点(IEEE754)を圧縮したい@dsirnlp#4
浮動小数点(IEEE754)を圧縮したい@dsirnlp#4
 
UIElements+UI BuilderでEditor拡張を作ろう
UIElements+UI BuilderでEditor拡張を作ろうUIElements+UI BuilderでEditor拡張を作ろう
UIElements+UI BuilderでEditor拡張を作ろう
 
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)
ARコンテンツ作成勉強会:Webブラウザで簡単作成!スマホAR(Zappar編)
 
【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現【Unity道場】VectorGraphicsで作る エモい表現
【Unity道場】VectorGraphicsで作る エモい表現
 
Usb接続するアプリを開発した時に試行錯誤した事
Usb接続するアプリを開発した時に試行錯誤した事Usb接続するアプリを開発した時に試行錯誤した事
Usb接続するアプリを開発した時に試行錯誤した事
 
CMake multiplatform build-tool
CMake multiplatform build-toolCMake multiplatform build-tool
CMake multiplatform build-tool
 
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね
【Unity道場スペシャル 2017札幌】カッコいい文字を使おう、そうtext meshならね
 
最近の単体テスト
最近の単体テスト最近の単体テスト
最近の単体テスト
 
NuGetの社内利用のススメ
NuGetの社内利用のススメNuGetの社内利用のススメ
NuGetの社内利用のススメ
 
モバイル通信を使わない 近接端末間通信対戦のレシピ
モバイル通信を使わない 近接端末間通信対戦のレシピモバイル通信を使わない 近接端末間通信対戦のレシピ
モバイル通信を使わない 近接端末間通信対戦のレシピ
 
UMLモデルを使った自動生成
UMLモデルを使った自動生成UMLモデルを使った自動生成
UMLモデルを使った自動生成
 
iOSアプリ UIテスト自動化入門
iOSアプリ UIテスト自動化入門iOSアプリ UIテスト自動化入門
iOSアプリ UIテスト自動化入門
 
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
【Unite Tokyo 2019】大量のオブジェクトを含む広いステージでも大丈夫、そうDOTSならね
 

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

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

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