This file contains 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
public function eat($food) | |
{ | |
switch ($food) { | |
case 'carrot': | |
$this->getCalories(50); | |
break; | |
case 'cabbage': | |
$this->getCalories(100); | |
break; | |
default: |
This file contains 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
$piecesOfCarrot = $carrot / 4; | |
foreach ($piecesOfCarrot as $pieceOfCarrot) { | |
$rabbit->eat($pieceOfCarrot); | |
} |
This file contains 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
// Cut the carrot into 4 pieces | |
$piecesOfCarrot = $carrot / 4; | |
// Let the rabbit eat all pieces of carrot one by one | |
foreach ($piecesOfCarrot as $pieceOfCarrot) { | |
$rabbit->eat($pieceOfCarrot); // Rabbit eats the piece of carrot | |
} |
This file contains 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 MovieSpec extends ObjectBehavior | |
{ | |
function it_should_have_john_smith_in_the_cast_with_a_lead_role() | |
{ | |
$this->getCast()->shouldHaveKeyWithValue('leadRole', 'John Smith'); | |
} | |
} |
This file contains 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
$conditions = new Condition(); | |
$untilCondition = (new Condition\Until())->findVegetables('carrot', 'cabbage'); | |
$turnBackCondition = (new Condition\TurnBack())->ifMeet('wolf', 'hunter'); | |
$conditions->add($untilCondition)->add($turnBackCondition); | |
$rabbit->run(Direction::FORWARD, $conditions); |
This file contains 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 Vapor | |
let drop = Droplet() | |
drop.get("hello") { request in | |
if let name = request.data["name"]?.string { | |
return try drop.view.make("hello", ["name": name]) | |
} | |
return try drop.view.make("hello", ["name": "no name"]) |
This file contains 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 func fontExplanation(questionTitle: String, | |
question: String, | |
wrongTitle: String?, | |
wrongAnswer: String?, | |
correctTitle: String, | |
correctAnswer: String, | |
explanationTitle: String, | |
explanation: String, | |
isCorrect: Bool) -> String { | |
This file contains 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
let pathToCss = Bundle.main.path(forResource: "styles", ofType: "css") | |
cell.webView.loadHTMLString(HtmlHelper.fontExplanation(questionTitle: questionTitle, | |
question: question, | |
wrongTitle: item!.is_correct! == false ? "YOUR ANSWER — | |
WRONG" : "", | |
wrongAnswer: item!.is_correct! == false ? wrongText : nil, | |
correctTitle: item!.is_correct! == false ? "CORRECT | |
ANSWER" : "YOUR ANSWER - CORRECT", | |
correctAnswer: correctText, |
This file contains 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
fileprivate var alertVC: UIAlertController = { | |
let vc = UIAlertController(title: "Warning", message: "No internet connection", | |
preferredStyle: .alert) | |
let action = UIAlertAction(title: "Ok", style: .default, handler: nil) | |
vc.addAction(action) | |
return vc | |
}() |
This file contains 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
//internet connection | |
UHBConnectivityManager.shared().registerCallBack({ [weak self] (status: | |
ConnectivityManagerConnectionStatus) in | |
if status == ConnectivityManagerConnectionStatusConnected { | |
print("Internet connected") | |
SocketManager.sharedInstance.reconnect() | |
self?.alertVC.dismiss(animated: true, completion: nil) | |
} else { |