Giter Site home page Giter Site logo

conditionalplacement's Introduction

ConditionalPlacement

The third project for iOS pre-course using conditionals.

Resources:

  • Read "Control Structures, Loops and Collections" intro to conditionals and the switch statement
  • For Objective-C make sure you've read all of RyPress's C Basics. It's a great resource to go back to when you have questions on how to do something in Objective-C
  • For Swift read "Section 1" of this Introduction to Swift. Feel free to read the whole thing, but you only need Section 1 for this project. Of course you can also read the section on Comparison Operators in the Apple Documentation

Step 1: Get the project started on your computer and on GitHub

  • Either create a project locally and push to GitHub
  • Or fork this project and clone it to your computer

Note:

  • For more detailed instructions of 'Step 1' see the first project
  • 'Step 1' is something we will do hundreds of times in class. You need to be able to do it quickly and without running into issues so it doesn't slow class down.

Step 2: Compare values and place in buckets

  • Declare two integers (karl and leonard)
  • Set the value of karl to 10 and leonard to 7
  • Declare two more integers (karlPlace and leonardPlace)

Step 3: Use a Ternary Operator to set values

  • You need to set those integers in the same line you create them using a ternary operator
    • Example: variablePlace = variable > 7 ? 1 : 2
    • That code checks if joshua is greater than 7 and if it is it sets joshuaPlace to 1 otherwise it sets it to 2
  • If karl is > 7 it should be set to 1 otherwise it should be set to 2
  • If leonard is > 7 leonardPlace should be set to 1 otherwise it should be set to 2

Step 4: Print out the placements

  • Check if leonardPlace and karlPlace are both equal to 1
    • If true log "Both teachers are placed 1"
  • If they are not both 1 check if karlPlace is equal to 1
    • If true log "Karl is placed 1 and Leonard is placed 2"
  • If karlPlace is not equal to 1 check if leonardPlace is equal to 1
    • If true log "Leonard is placed 1 and Karl is placed 2"
  • If leonardPlace is not equal to 1
    • If that's false as well, log "Karl and Leonard are placed 2"

Completion:

  • It should print that "Karl is placed 1 and Leonard is placed 2"
  • Feel free to play with the scores of each name and validate that your placement check work correctly

conditionalplacement's People

Contributors

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