FizzBuzzWhizz design mode solution

Source: Internet
Author: User

The recruitment done by lagu is too successful, and n people know this problem. So many people are writing this question in the blog Park. But, boy, do you think what you wrote meets the meaning of the question? Or do you understand the question? The Code requirements clearly suggest writing unit tests, and some people do not feel very comfortable with unit tests. Of course, I don't know much about unit testing either. Object-oriented is mentioned in the Code requirements. But, young man, do you develop it into an algorithm? Is it an ACM-born master? Reduce the complexity of the circle as mentioned in the code requirement. Look at your complexity. I wrote a few titles first. In fact, I initially thought it was an algorithm to optimize things. Then I googled it and learned about the responsibility chain model. Coincidentally, I have always hoped to study the design model well and learn it through this question. Code requirements: there are no restrictions on the language. Java, C #, Ruby, C ++, Js, Python, Scala, and objective-C can all be used. It is fine for small languages, as long as you are good at it; it is strongly recommended to write unit tests. Show your superb object-oriented/functional programming skills. We recommend that you reduce the complexity of the cycle as much as possible. Please submit executable code, and Related build scripts/Instructions (code running platform and environment); FizzBuzzWhizz Requirement Description you are a PE Instructor, five minutes before a class, you decide to make a game. At this time, 100 students are attending classes. The rule of the game is: you first say three different special numbers, which must be single digits, such as 3, 5, and 7. Let all the students form a team and then report in order. When a student reports a number, if the number is a multiple of the first Special Number (3), it cannot be said, rather than Fizz; if the number is the second special number (5) buzz. If the number is a multiple of the third special number (7), Whizz is used. When a student reports a number, if the number is a multiple of two special numbers at the same time, special processing is also required, such as the first Special number and the second special number, the number cannot be said, but FizzBuzz, and so on. If it is a multiple of three special numbers, FizzBuzzWhizz should be used. When a student reports a number, if the number contains the first special number, the number cannot be used, but the corresponding word is used. For example, the First Special number in this example is 3, so the student who needs to report the message 13 should say Fizz. If the number contains the first special number, rule 3 and rule 4 are ignored. For example, if you want to report to 35, only Fizz is reported, but BuzzWhizz is not reported. Now, we need you to complete a program to simulate this game. It first accepts three special numbers and then outputs the numbers or words that 100 students should report. For example, input 3, 5, and 7 outputs (fragment) 12Fizz4BuzzFizzWhizz8FizzBuzz11FizzFizzWhizzFizzBuzz1617Fizz19Buzz... Until 100 design mode Responsibility Chain mode development environment Windows 7x64 + Visual Studio 2013 unit test using Visual Studio 2013 with test framework related information [refactoring to Mode-Chain of Responsibility Pattern] Fizz buzz moves to rebuild to the responsible chain mode test case 3, 5, 75, 3, 71, 2, 32, 4, 83, 6, 9 There is a bug in running the unit test to solve the problem. Some unit test cases fail when running all unit test cases. Currently, the cause of the failure case is not debugged. According to the message of the failure case, the same value should be obtained when fizz, buzz, and whizz are set, but this situation cannot be debugged during debugging. To solve this problem, you can record the log and debug it. If you are busy with other things, you have no time to test it. Putting all similar tests in the same test case should not be a good habit. We should gradually break them down into different test cases and look forward to how to organize the test cases under the guidance of Daniel. The FizzBuzzSame () and BuzzFizzSame () in the test case should trigger the ArgumentException of fizz in the BuzzFizzSame () test case. Obviously, this has not been implemented yet, is there a better solution?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.