Giter Site home page Giter Site logo

swift-arraychallengetoo-lab-dumbo-web-82619's Introduction

Array Challenge Deuce Lab

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.
  • 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.

Locate the Deli.swift file. It is your job to implement the functions below:

The function definitions have been created for you, it's your job to implement them!

  • 1. Implement this function - addNameToLine(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 argument to the line stored property on the Deli class. (Exactly what that sentence means is explained when we get to the section on Classes). For now, you can see that line is created for you as an empty array of String 's. You can utilize this variable within all of the functions you create, you have full access to it.
      • 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 Crystal! You can sit wherever you like."
      • If the persons name is Meg Ryan: "Welcome Meg Ryan! 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 - lineDescription()

    • 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-dumbo-web-82619's People

Contributors

jimcampagno avatar ianrahman avatar annjohn avatar pletcher avatar johann avatar jellybeanjohnny avatar ipc103 avatar

Watchers

 avatar Mohawk Greene avatar Victoria Thevenot avatar Bernard Mordan avatar Otha avatar raza jafri avatar  avatar Joe Cardarelli avatar The Learn Team avatar Sophie DeBenedetto avatar  avatar  avatar Matt avatar Antoin avatar  avatar Alex Griffith avatar  avatar Amanda D'Avria avatar  avatar Ahmed avatar Nicole Kroese  avatar Kaeland Chatman avatar Lisa Jiang avatar Vicki Aubin avatar Maxwell Benton 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.