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 Reflect】どんなものか試してみよう〜基礎編〜
【Unity Reflect】どんなものか試してみよう〜基礎編〜【Unity Reflect】どんなものか試してみよう〜基礎編〜
【Unity Reflect】どんなものか試してみよう〜基礎編〜Unity Technologies Japan K.K.
 
Tutorial Animasi menggunakan macromedia Flash 8
Tutorial Animasi menggunakan macromedia Flash 8Tutorial Animasi menggunakan macromedia Flash 8
Tutorial Animasi menggunakan macromedia Flash 8Farichah Riha
 
UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!Unity Technologies Japan K.K.
 
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】GMO GlobalSign Holdings K.K.
 
Unityではじめるオープンワールド制作 エンジニア編
Unityではじめるオープンワールド制作 エンジニア編Unityではじめるオープンワールド制作 エンジニア編
Unityではじめるオープンワールド制作 エンジニア編Unity Technologies Japan K.K.
 
Mayaカメラデータunityインストール
MayaカメラデータunityインストールMayaカメラデータunityインストール
Mayaカメラデータunityインストール小林 信行
 
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみた
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみたHoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみた
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみたFranz Weitl
 
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーションビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - UnityステーションUnity Technologies Japan K.K.
 
ゲームAI入門(前半)
ゲームAI入門(前半)ゲームAI入門(前半)
ゲームAI入門(前半)Youichiro Miyake
 
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻poko ponmaru
 
Killzone Shadow Fall: Creating Art Tools For A New Generation Of Games
Killzone Shadow Fall: Creating Art Tools For A New Generation Of GamesKillzone Shadow Fall: Creating Art Tools For A New Generation Of Games
Killzone Shadow Fall: Creating Art Tools For A New Generation Of GamesGuerrilla
 
MMORPGで考えるレベルデザイン
MMORPGで考えるレベルデザインMMORPGで考えるレベルデザイン
MMORPGで考えるレベルデザインKatsumi Mizushima
 
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜めーぷる しろっぷ
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3stevemcauley
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationGuerrilla
 

What's hot (20)

【Unity Reflect】どんなものか試してみよう〜基礎編〜
【Unity Reflect】どんなものか試してみよう〜基礎編〜【Unity Reflect】どんなものか試してみよう〜基礎編〜
【Unity Reflect】どんなものか試してみよう〜基礎編〜
 
Tutorial Animasi menggunakan macromedia Flash 8
Tutorial Animasi menggunakan macromedia Flash 8Tutorial Animasi menggunakan macromedia Flash 8
Tutorial Animasi menggunakan macromedia Flash 8
 
Adobe Premiere Pro.ppt
Adobe Premiere Pro.pptAdobe Premiere Pro.ppt
Adobe Premiere Pro.ppt
 
UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!UnityのクラッシュをBacktraceでデバッグしよう!
UnityのクラッシュをBacktraceでデバッグしよう!
 
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
Unityで PhotonCloudを使ってリアルタイム・マルチプレイヤーゲームを作っちゃおう【導入編】
 
Unityではじめるオープンワールド制作 エンジニア編
Unityではじめるオープンワールド制作 エンジニア編Unityではじめるオープンワールド制作 エンジニア編
Unityではじめるオープンワールド制作 エンジニア編
 
Mayaカメラデータunityインストール
MayaカメラデータunityインストールMayaカメラデータunityインストール
Mayaカメラデータunityインストール
 
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみた
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみたHoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみた
HoloLens で OpenCV をどう使うか レーザーポインター 認識で試してみた
 
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーションビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
ビジュアルスクリプティングで始めるUnity入門2日目 ゴールとスコアの仕組み - Unityステーション
 
9. control scratch
9. control scratch9. control scratch
9. control scratch
 
ゲームAI入門(前半)
ゲームAI入門(前半)ゲームAI入門(前半)
ゲームAI入門(前半)
 
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
MAYAで作ったアニメーションをUnityに取り込んで動かしてみるの巻
 
Killzone Shadow Fall: Creating Art Tools For A New Generation Of Games
Killzone Shadow Fall: Creating Art Tools For A New Generation Of GamesKillzone Shadow Fall: Creating Art Tools For A New Generation Of Games
Killzone Shadow Fall: Creating Art Tools For A New Generation Of Games
 
MRTK-Unreal(UX Tools) を利用した HoloLens 2 アプリ開発 | UNREAL FEST EXTREME 2020 WINTER
MRTK-Unreal(UX Tools) を利用した HoloLens 2 アプリ開発 | UNREAL FEST EXTREME 2020 WINTERMRTK-Unreal(UX Tools) を利用した HoloLens 2 アプリ開発 | UNREAL FEST EXTREME 2020 WINTER
MRTK-Unreal(UX Tools) を利用した HoloLens 2 アプリ開発 | UNREAL FEST EXTREME 2020 WINTER
 
MMORPGで考えるレベルデザイン
MMORPGで考えるレベルデザインMMORPGで考えるレベルデザイン
MMORPGで考えるレベルデザイン
 
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜
はじめてのこんぴゅうとしぇえだあ〜ComputeShaderに入門してみた話〜
 
UE4を使用したバーチャルヒューマンの映像制作 UNREAL FEST EXTREME 2021 SUMMER
UE4を使用したバーチャルヒューマンの映像制作  UNREAL FEST EXTREME 2021 SUMMERUE4を使用したバーチャルヒューマンの映像制作  UNREAL FEST EXTREME 2021 SUMMER
UE4を使用したバーチャルヒューマンの映像制作 UNREAL FEST EXTREME 2021 SUMMER
 
UE4を用いたTPS制作事例 EDF:IR レベル構成について
UE4を用いたTPS制作事例 EDF:IR レベル構成についてUE4を用いたTPS制作事例 EDF:IR レベル構成について
UE4を用いたTPS制作事例 EDF:IR レベル構成について
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
 

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

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

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