Git Product home page Git Product logo

swift-arraychallengetoo-lab-ios-0916's Introduction

Array Challenge Deuce

haveWhatSheshaving

[to waiter] I'll have what she's having. -Estelle Reiner

Learning Objectives

  • Write a method that takes in an array, performs some checks and returns a new array.
  • Call on created method in viewDidLoad().
  • Read and run unit tests to check your work.

Instructions

Lets pretend for this lab that we own a deli.

Our deli is one of the busiest delis in New York City (therefore one of the busiest on Earth). Our job is to create a system that represents a line. Someone enters the store, they enter our line. Our server then needs to able to state "Now serving x!" x being the individuals name. There's one catch! If our customer is either Meg Ryan or Billy Crystal, they will jump to the front of the line.

  • 1. Implement this function - addNameToDeliLine(name:)

    • It should take in a String as one of its arguments (labeled as name) and return a String.
    • In its implementation, it should add the name passed into this function to the deliLine property on the ViewController with a few conditions:
      • If the persons name is Billy Crystal, they should be positioned at the front of the line.
      • If the persons name is Meg Ryan, they should be positioned at the front of the line.
      • Everyone else should be added to the back of the line and wait their turn.
    • The String this function should return is based on the following conditions (x represents the individuals name, y represents their position in line).
      • If the person is first in line: "Welcome x, you're first in line!"
      • If the persons name is Billy Crystal: "Welcome Billy! You can sit wherever you like."
      • If the persons name is Meg Ryan: "Welcome Meg! You can sit wherever you like."
      • Every other situation: "Welcome x, you're number y in line."
  • 2. Implement this function - nowServing()

    • It should take in no arguments but return back a String.
    • In its implementation the String that is returned is based on the following conditions (x represents the individuals name):
      • If the line is empty: "There is no one to be served."
      • If the line isn't empty: "Now serving x!"
    • This function should do one more thing. It should remove the individual from the deliLine that it's about to serve.
  • 3. Implement this function - deliLineDescription()

    • This function should take no arguments but return back a String.
    • The String to be returned back is based on the following conditions:
      • If the line is empty: "The line is currently empty."
      • Otherwise, return a String beginning with the "The line is:", and appending every customer in the line on a new line \n beginning with their number in the line. For example, if our line was represented as:
var line = ["Albert Einstein", "Cher", "Neil deGrasse Tyson", "Yoshi"]

The String to be returned should look like this:

"The line is:

  1. Albert Einstein
  2. Cher
  3. Neil deGrasse Tyson
  4. Yoshi"

deli

View Array Challenge Deuce Lab on Learn.co and start learning to code for free.

swift-arraychallengetoo-lab-ios-0916's People

Contributors

jimcampagno avatar ianrahman avatar annjohn avatar pletcher avatar jellybeanjohnny avatar fsjohnson avatar ipc103 avatar

Watchers

 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.