Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completed Assignment #55

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Completed step 8-10
  • Loading branch information
nelglez committed Jan 16, 2020
commit 59c71ed0b893bcad358ac43388d6e969e05cbe3c
24 changes: 22 additions & 2 deletions NOCList.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -111,17 +111,37 @@ func findHighRisk() {
//: ## Step 8
//: Call the above function and check the output in the console to ensure it is functioning properly.


findHighRisk()

//: ## Step 9
//: Create a function that finds totals for low, mid, and high level agents. Low level agents are 4 or lower, mid are 5-7, and high level agents are 8 or above. Iterate over each agent and use a `switch` statement to determine their level group. At the end of the function, print a statement like the following: "# low level agents, # mid level agents, and # high level agents"
func findTotalsForAgentsLevel() {
var lowLevelAgents = 0
var midLevelAgents = 0
var highLevelAgents = 0

for agent in agentsArray {
switch agent.accessLevel {
case 0...4:
lowLevelAgents += 1
case 5...7:
midLevelAgents += 1
case let x where x >= 8:
highLevelAgents += 1
default:
break
}
}

print("\(lowLevelAgents) low level agents, \(midLevelAgents) mid level agents, and \(highLevelAgents) high level agents")
}



//: ## Step 10
//: Call the above function and check its output in the console.


findTotalsForAgentsLevel()

//: ## Step 11 (Optional)
//: Create and call a function that prints the cover names and access levels of all agents, but the list should be sorted by access level, in ascending order.