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
| from flask import Flask | |
| from flask_restful import Api, Resource, reqparse | |
| app = Flask(__name__) | |
| api = Api(app) | |
| users = [ | |
| { | |
| "name": "Nicholas", | |
| "age": 42, |
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
| //month names, weekday names, and ordinal indicators are in English | |
| // Date.now() | |
| // Date.fromISOString(isoStr) | |
| // Date.timeBetween(date1, date2) | |
| // dat.isLeapYear() | |
| // dat.isUTCLeapYear() | |
| // dat.getDaysInMonth() | |
| // dat.getUTCDaysInMonth() | |
| // dat.getMonthName() |
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
| /** | |
| * This method is called when the plus button is clicked. | |
| */ | |
| public void increment(View view) { | |
| if (quantity == 100) { | |
| // Show an error message as a toast | |
| Toast.makeText(this, "You cannot have more than 100 coffees", Toast.LENGTH_SHORT).show(); | |
| // Exit this method early because there's nothing left to do | |
| return; | |
| } |
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
| int numberOfSmoothiesTillPrize = 10; | |
| if (numberOfSmoothiesTillPrize > 9) { | |
| Log.v("SmoothieActivity", "Congratulations, you get a free smoothie!"); | |
| numberOfSmoothiesTillPrize = numberOfSmoothiesTillPrize - 10; | |
| } else { | |
| Log.v("SmoothieActivity", "No free smoothie this time."); | |
| } | |
| Log.v("SmoothieActivity", "You currently have " + numberOfSmoothiesTillPrize + " out of 10 smoothies needed for your next free smoothie."); |
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
| private String createCalendarEventReminder(String eventName, String location, int minutesAway) { | |
| String reminder = "You have an upcoming event in " + minutesAway + " minutes."; | |
| reminder = reminder + " It is " + event + " held at " + location + "."; | |
| return reminder; | |
| } |
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
| /** | |
| * Calculates the price of the order based on the current quantity. | |
| * | |
| * @return the price | |
| */ | |
| private int calculate price(int quantity { | |
| int price = quantity * 5; | |
| return price; | |
| } |