Refactoring exercise according to Chapter 1 of Martin Fowler's book: "Refactoring, Improving the Design of Existing Code".
Martin Fowler is one of the most famous Software Engineers EVER. It is worth to spend some time with his writings. He wrote this book in 1999! So you can imagine .... Many things he does by hand are automated by your IDE! Use that automation. Consider this an exercise in dealing with legacy code. Because of course, you would NEVER write code like this. Your IDE wouldn't let you! This is called error prevention.