Goal: Continue building out applications using MSTest and the "Red, Green, Refactor" workflow.
Follow along with the homework and create the To Do List app. After writing tests for the backend logic, create a Program
class to interact with a user through the console. The app should allow the user to add new items to a to do list. The user should also be able to see a list of the tasks they have already added.
For example, the program could work like this:
Consider what the program should print if the user asks to view their list before they have added any items to it.
Given a number, write a method that returns all of the prime numbers less than that number.
This is a tricky problem and you should use the Sieve of Eratosthenes to solve it. Here's how the Sieve of Eratosthenes works to find a number up to a given number
:
number
.prime
equal 2, the first prime number.prime
, remove all multiples of prime
from the list.prime
by 1.number
, all the remaining numbers in the list are primes.You also might find this video helpful in explaining the Sieve.
Recreate the game Rock, Paper, Scissors. For anyone who has never played it, here are the rules:
Rock v. Scissors = Rock wins Rock v. Paper = Paper wins Paper v. Scissors = Scissors wins
Write a method that can handle the different combinations of plays and make sure to write specs for all possible combination of plays. Your method should take 2 inputs - one for each player's choice. It should return "Player 1" if the first input wins, "Player 2" if the second input wins, and "Draw" if nobody wins.
Start by considering all possible inputs and outputs. Then choose the simplest input/output values and use them to write your first spec. Write all specs in English first, and then translate them into test methods and make them pass, one by one. Don't start coding until you've written your English specs.
Make sure you include a README for this project and create a Git repository for it.
If you get this far, you've done great! Don't worry about getting to the rest of the projects by the end of the day.
Here's optional further exploration to explore:
Make an console app that allows users to input a day of the year (like 7/11/2014) and then write a method to find out what day of the week it was, i.e. Monday, Tuesday, etc. Make sure you start with your specs and include a README for this project and create a Git repository for it.
Lesson 1 of 12
Last updated more than 3 months ago.