In some English accents, when you say "two for" quickly, it sounds like "two fer". Two-for-one is a way of saying that if you buy one, you also get one for free. So the phrase "two-fer" often implies a two-for-one offer.
Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). You take the offer and (very generously) decide to give the extra cookie to someone else in the queue.
Your task is to determine what you will say as you give away the extra cookie.
If you know the person's name (e.g. if they're named Do-yun), then you will say:
One for Do-yun, one for me.
If you don't know the person's name, you will say you instead.
One for you, one for me.
Here are some examples:
Name | Dialogue |
---|---|
Alice | One for Alice, one for me. |
Bohdan | One for Bohdan, one for me. |
One for you, one for me. | |
Zaphod | One for Zaphod, one for me. |
Before you start, make sure you understand how to write code that can pass the test cases. For more context, check out this tutorial.
Most Java exercises include multiple test cases. These cases are structured to support a useful process known as test-driven development (TDD). TDD involves repeating a structured cycle that helps programmers build complex functionality piece by piece rather than all at once. That cycle can be described as follows:
The test files in this track contain all the tests your solution should pass to be considered valid. That doesn't immediately seem to be compatible with the cycle described above, in which tests are written one by one. However, the tool that we use to write our tests, JUnit, provides a @Disabled annotation that can be used to temporarily skip an already-written test. Using this annotation, we make sure that the test files we deliver to you satisfy the following rules:
This allows you to simulate the TDD cycle by following these slightly-modified steps:
@Disabled
annotation in the test file.Sign up to Exercism to learn and master Java with 25 concepts, 148 exercises, and real human mentoring, all for free.