Coder Social home page Coder Social logo

wwdc-badges-methods-001's Introduction

WWDC 2.0

Objectives

  1. Write custom methods to solve a few simple problems.
  2. Call your methods to get the results that you need.
  3. Run the tests to check your work.

Premise

You did such a great job last year at the Apple Worldwide Developers Conference that they've asked for you back—and now they want you to handle a few more tasks as well. It's more work than you could possible handle by yourself given the time frame, so you'll need to figure out how to pass off the intructions by creating some methods!

The speaker list is new this year, but it boasts a similarly astounding group.

In addition to the name tags, the conference manager also wants you to print a personalized greeting for each speaker to inform each of them of their dressing room assignment back stage.

Instructions

  1. Open the *.xcworkspace and read the unit tests in AppDelegateSpec. Try to understand what each test is expecting to happen. (Do not copy/paste the expected arrays from the tests into your method body. These are matchers for what your methods should produce programmatically at run time.) You'll notice that Xcode generates three errors that show up in the Issue Navigator like this: This is normal and it just means that Xcode can't find the methods that are called in the tests—but of course it can't, you haven't written them yet!

  2. Navigate to the AppDelegate.h header file. Declare three (-) instance methods within the @interface:

  • makeBadgeForSpeaker: that accepts one NSString argument named speaker and returns an NSString
  • makeAllBadgesForSpeakers: that accepts one NSArray argument named speakers and returns an NSMutableArray
  • greetAndAssignRoomsToSpeakers: that accepts on NSArray argument and named speakers and returns an NSMutableArray
  1. Navigate to the AppDelegate.m implementation file. Using autocomplete, fill out the names of each method and define them to return nil (these minimum definitions are required to get those three errors to disappear and the test build to succeed). Run the tests (⌘``U) to make sure that the build succeeds but that the tests initially fail.

  2. Redefine makeBadgeForSpeaker: to return an interpolated string that includes the speaker's name submitted through the argument, in the manner of Hello, my name is <#speaker#>.. Run the test that checks this method and tweak your method until it the test passes.

  3. Redefine makeAllBadgesForSpeakers: to call makeBadgeForSpeaker: on each string in the speakers array submitted through the NSArray argument; capture its return string into a new NSMutableArray declared within the method. Hint: Use a for loop to iterate over the argument array and add the result of each makeBadgeForSpeaker: method call to the mutable array. Return the mutable array. Then, run the test for this method and tweak your method body until the test passes.

  4. Redefine the greetAndAssignRoomsToSpeakers: method to iterate over the speakers argument array and create an interpolated string with each speaker's name and their dressing room number (which range from 1 through 8). The interpolated string should read: Welcome, <#speaker#>! You'll be in dressing room <#roomNumber#>. Add each string to a mutable array. Return the mutable array, then run the test and tweak your method body until the test passes.

wwdc-badges-methods-001's People

Contributors

chrisgonzgonz avatar markedwardmurray avatar zdrossman avatar fs-lms-test-bot avatar jmburges avatar jkiley129 avatar mykelp avatar fislabstest avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.