Você foi contratado para criar um sistema simples de treino Pokémon.
O sistema deve permitir que Pokémons sejam criados, treinados e que suas informações sejam consultadas.
Enunciado: Crie uma função chamada soma
que recebe dois números inteiros e retorna a soma deles.
Enunciado: Crie uma função chamada ehPar
que recebe um número inteiro e retorna true
se ele for par e false
caso contrário.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension Data { | |
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription | |
guard let object = try? JSONSerialization.jsonObject(with: self, options: []), | |
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]), | |
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil } | |
return prettyPrintedString | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DiskStatus { | |
// MARK: Get String Value | |
class var totalDiskSpace: String { | |
get { | |
return ByteCountFormatter.string(fromByteCount: totalDiskSpaceInBytes, countStyle: ByteCountFormatter.CountStyle.file) | |
} | |
} | |
class var freeDiskSpace: String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// If an error occurs while getting the amount of memory used, the first returned value in the tuple will be 0. | |
func getMemoryUsedAndDeviceTotalInMegabytes() -> (Float, Float) { | |
// https://stackoverflow.com/questions/5887248/ios-app-maximum-memory-budget/19692719#19692719 | |
// https://stackoverflow.com/questions/27556807/swift-pointer-problems-with-mach-task-basic-info/27559770#27559770 | |
var used_megabytes: Float = 0 | |
let total_bytes = Float(ProcessInfo.processInfo.physicalMemory) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ExtensionURLRequest.swift | |
// | |
// Created by Abhishek Maurya on 16/07/20. | |
// Copyright © 2020. All rights reserved. | |
// | |
import Foundation | |
extension URLRequest { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController: UIViewController { | |
private(set) var tap: UITapGestureRecognizer | |
init(tap: UITapGestureRecognizer) { | |
self.tap = tap | |
super.init(nibName: nil, bundle: nil) | |
} | |
required init?(coder: NSCoder) { |
NewerOlder