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

[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머포프 김
 
6. satuan percobaan, dan percobaan satu faktor
6. satuan percobaan, dan percobaan satu faktor6. satuan percobaan, dan percobaan satu faktor
6. satuan percobaan, dan percobaan satu faktorEmi Suhaemi
 
Pemasaran hasil pertanian
Pemasaran hasil pertanianPemasaran hasil pertanian
Pemasaran hasil pertanianGuntur Raharjo
 
【Unite Tokyo 2019】2DアーティストのためのGPU入門
【Unite Tokyo 2019】2DアーティストのためのGPU入門【Unite Tokyo 2019】2DアーティストのためのGPU入門
【Unite Tokyo 2019】2DアーティストのためのGPU入門UnityTechnologiesJapan002
 
ホモ・ルーデンス - ヨハン・ホイジンガ
ホモ・ルーデンス - ヨハン・ホイジンガホモ・ルーデンス - ヨハン・ホイジンガ
ホモ・ルーデンス - ヨハン・ホイジンガMint Yoshida
 
ジラフとアンニカの写真撮影機能の制作事例
ジラフとアンニカの写真撮影機能の制作事例ジラフとアンニカの写真撮影機能の制作事例
ジラフとアンニカの写真撮影機能の制作事例Kami pallet
 
(文献紹介)HDR+, Night Sight
(文献紹介)HDR+, Night Sight(文献紹介)HDR+, Night Sight
(文献紹介)HDR+, Night SightMorpho, Inc.
 
Physically Based Lighting in Unreal Engine 4
Physically Based Lighting in Unreal Engine 4Physically Based Lighting in Unreal Engine 4
Physically Based Lighting in Unreal Engine 4Lukas Lang
 
Textual Analysis of Til It Happens To You by Lady Gaga
Textual Analysis of Til It Happens To You by Lady GagaTextual Analysis of Til It Happens To You by Lady Gaga
Textual Analysis of Til It Happens To You by Lady Gagadaisyq2
 
PENGENALAN MASALAH - mengenali masalah
PENGENALAN MASALAH - mengenali masalahPENGENALAN MASALAH - mengenali masalah
PENGENALAN MASALAH - mengenali masalahAa Renovit
 
Konsep dasar probabilitas
Konsep dasar probabilitasKonsep dasar probabilitas
Konsep dasar probabilitaspadlah1984
 
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"Lviv Startup Club
 
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術Unity Technologies Japan K.K.
 
2903436 modul-9-benefit cost-ratio-analysis
2903436 modul-9-benefit cost-ratio-analysis2903436 modul-9-benefit cost-ratio-analysis
2903436 modul-9-benefit cost-ratio-analysispuput075
 
Pengertian distribusi lognormal
Pengertian distribusi lognormalPengertian distribusi lognormal
Pengertian distribusi lognormalNurul Lailyah
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingElectronic Arts / DICE
 
感性情報心理学(4/4)
感性情報心理学(4/4)感性情報心理学(4/4)
感性情報心理学(4/4)Masashi Komori
 

What's hot (20)

[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머
 
6. satuan percobaan, dan percobaan satu faktor
6. satuan percobaan, dan percobaan satu faktor6. satuan percobaan, dan percobaan satu faktor
6. satuan percobaan, dan percobaan satu faktor
 
Pemasaran hasil pertanian
Pemasaran hasil pertanianPemasaran hasil pertanian
Pemasaran hasil pertanian
 
【Unite Tokyo 2019】2DアーティストのためのGPU入門
【Unite Tokyo 2019】2DアーティストのためのGPU入門【Unite Tokyo 2019】2DアーティストのためのGPU入門
【Unite Tokyo 2019】2DアーティストのためのGPU入門
 
ホモ・ルーデンス - ヨハン・ホイジンガ
ホモ・ルーデンス - ヨハン・ホイジンガホモ・ルーデンス - ヨハン・ホイジンガ
ホモ・ルーデンス - ヨハン・ホイジンガ
 
ジラフとアンニカの写真撮影機能の制作事例
ジラフとアンニカの写真撮影機能の制作事例ジラフとアンニカの写真撮影機能の制作事例
ジラフとアンニカの写真撮影機能の制作事例
 
(文献紹介)HDR+, Night Sight
(文献紹介)HDR+, Night Sight(文献紹介)HDR+, Night Sight
(文献紹介)HDR+, Night Sight
 
Physically Based Lighting in Unreal Engine 4
Physically Based Lighting in Unreal Engine 4Physically Based Lighting in Unreal Engine 4
Physically Based Lighting in Unreal Engine 4
 
Textual Analysis of Til It Happens To You by Lady Gaga
Textual Analysis of Til It Happens To You by Lady GagaTextual Analysis of Til It Happens To You by Lady Gaga
Textual Analysis of Til It Happens To You by Lady Gaga
 
PENGENALAN MASALAH - mengenali masalah
PENGENALAN MASALAH - mengenali masalahPENGENALAN MASALAH - mengenali masalah
PENGENALAN MASALAH - mengenali masalah
 
Konsep dasar probabilitas
Konsep dasar probabilitasKonsep dasar probabilitas
Konsep dasar probabilitas
 
Manpro sesi 1
Manpro sesi 1Manpro sesi 1
Manpro sesi 1
 
"有翼のフロイライン Wing of Darkness"と歩むUE4の世界
"有翼のフロイライン Wing of Darkness"と歩むUE4の世界"有翼のフロイライン Wing of Darkness"と歩むUE4の世界
"有翼のフロイライン Wing of Darkness"と歩むUE4の世界
 
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"
Mikhail Kyyashko "PBR (physically based rendering) for artists and programmers"
 
Sumber daya hutan
Sumber daya hutanSumber daya hutan
Sumber daya hutan
 
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
【Unite 2017 Tokyo】最適化をする前に覚えておきたい技術
 
2903436 modul-9-benefit cost-ratio-analysis
2903436 modul-9-benefit cost-ratio-analysis2903436 modul-9-benefit cost-ratio-analysis
2903436 modul-9-benefit cost-ratio-analysis
 
Pengertian distribusi lognormal
Pengertian distribusi lognormalPengertian distribusi lognormal
Pengertian distribusi lognormal
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
 
感性情報心理学(4/4)
感性情報心理学(4/4)感性情報心理学(4/4)
感性情報心理学(4/4)
 

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

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 

Recently uploaded (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
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
 

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