David Prieto
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Functions signatures :::info Disclaimer. This is written in C++ but the concept of signature is similar in java and pseudocode. These are exercises for the students to check they proficiency in understanding functions when they are described. ::: Reference: https://developer.mozilla.org/en-US/docs/Glossary/Signature/Function The concept of function signature (in general) includes * name of method * input (list of parameters and their type if it's a highly typed programming language) * output type * exceptions that can be passed or throwed (advanced concept) * availability of the method in OOP (static, public, private) :::warning In IB the method signature is only the name, parameter list and their type. ::: ### Exercise 1 Write the signature (the definition of the function) of the following findTheLeg is a function that given an hypotenuse and another leg is going to return a leg. Legs and hypothenuses are doubles. :::spoiler ```cpp double findTheLeg( double hypotenuse, double otherLeg) ``` ::: validateDNI is a function that given a string is going to return true if it's a valid DNI and false otherwise. :::spoiler ```cpp bool validateDNI(String x) ``` ::: createBigHouseInMinecraft is a function that it's going to try to create a big luxury house in survival in Minecraft. If it achieves it, the function is going to return true and is going to return false if there was an error :::spoiler ```cpp bool createBigHouseInMinecraft() ``` ::: createBigHouseInMinecraft is a function that it's going to try to create a big luxury house in survival in Minecraft. There is a parameter x that is the IP where the server is (the object IP stores IP addresses) If it achieves it, the function is going to return true and is going to return false if there was an error :::spoiler ```cpp bool createBigHouseInMinecraft(IP server) ``` ::: There is an object to store Vectors called PVector. We are going to implement a function to add 2 of these vectors returning the PVector resulted from them. The function is called addPVector :::spoiler ```cpp PVector addPVector (PVector x, PVector y) ``` ::: Define a function that is going to print the n number of the fibonacci series given as an integer. The name of the function is printFib :::spoiler ```cpp void printFib (int n) ``` ::: Define a function that is going to sound a scale given the number of the pin where the buzzer is attached. The name of the function is soundScale. :::spoiler ```cpp void soundScale (int pin) ``` ::: Define a function that is going to sound a scale given the number of the pin where the buzzer is attached and a boolean that is true if we want to play a chormatic scale and false otherwise. The name of the function is soundScale :::spoiler ```cpp void soundScale (int pin, bool chromatic) void soundScale ( bool chromatic, int pin) ``` ::: Define a function that is given the milliseconds that have passed, is going to return if it's time to go to the next class or not. The name of the function is nextClassAlready. Milliseconds use the type long. :::spoiler ```cpp bool nextClassAlready(long milliseconds) ``` ::: Define a function that is given the milliseconds that have passed, is going to return if it's time to go to the next class or not. The coding for knowing if it's the next class is that is going to return 1 if we have to go to the next class and 0 otherwise. The name of the function is nextClassAlready. Milliseconds use the type long. :::spoiler ```cpp int nextClassAlready(long milliseconds) ``` ::: :::info The function digitalRead(int pin) returns an int. 1 (HIGH) or 0 (LOW) ::: Define the Function HTTPConnect that is going to return a code that is an integer for the status of the connection given the URL as a string :::spoiler ```cpp int HTTPConnect(string URL) ``` ::: ### Exercises 2 Define the function startWithQuixote that if you send an String is going to return an string that is the same but it will start with "En un lugar de la Mancha... ". :::spoiler ```cpp String startWithQuixote(String s) ``` ::: Define a function that is going to output on a screen (or through serial) the inverse (1/x) of the integer number that you send to it. The name of the function is inverseNumber :::spoiler ```cpp void inverseNumber(int n) ``` ::: Define a function in C++ that is going to return true if it's a "good day" and false otherwise. The name of the function is "isItAGoodDay". :::spoiler ```cpp bool isItAGoodDay() ``` ::: Define a function in C++ that is going to return you the volume of a cilinder given it's radius and it's height. Numbers can be decimals. The name of the function is volumeCilinder. double volumeCilinder(double radio, double height) Define a function called "isThereAnyBeetlejuice" that is going to analyse a string given as a parameter and is going to return true if the name "Beetlejuice" is part of the string and false otherwise ![Bitelchaus-121077102-large](https://hackmd.io/_uploads/rJM778UtT.jpg) :::spoiler ```cpp bool isThereAnyBeetlejuice(string x) ``` ::: Define a function that is called notOver5 that given an integer is going to return the same integer if it's not over 5 and 5 if it's equal or bigger than five. :::spoiler ```cpp int notOver5 (int n) ``` ::: ## Variations of lullaby These are all functions that they do the same thing (mostly) but they are defined each somewhat differently so they have different parameters and return types. You can use this to notice different partterns. ![imagen](https://hackmd.io/_uploads/H1rTELLtT.png) _jigglypuff_ Define a function called singLullaby that is going to tone a lullaby when called. :::spoiler ```cpp void singLullaby() ``` ::: Define a function called singLullaby that is going to tone a lullaby when called from a number of possible lullaby songs. The number of the song has to be provided. :::spoiler ```cpp void singLullaby(int song) ``` ::: Define a function called singLullaby that is going to tone a lullaby when called from a number of possible lullaby songs. The number of the song has to be provided, also the pin where the buzzer is set. :::spoiler ```cpp void singLullaby(int song, int pin) ``` ::: Define a function called singLullaby that is going to tone a lullaby when called. Since singing is difficult, this method will return true if has achieved to sing the full lullaby and false if there was any kind of error during execution. :::spoiler ```cpp bool singLullaby() ``` ::: Define a function called singLullaby that is going to tone a lullaby when called. Since singing is difficult, this method will return 1 if has achieved to sing the full lullaby and 0 if there was any kind of error during execution. :::spoiler ```cpp int singLullaby() ``` ::: Define a function called singLullaby that is going to tone a lullaby when called. Since singing is difficult, this method will return a code that will go from 100 to 600 like if it was a http request. :::spoiler ```cpp int singLullaby() ``` ::: Define a function called singLullaby that is going to tone a lullaby when called from a number of possible lullaby songs. The number of the song has to be provided, also the pin where the buzzer is set. Since singing is difficult, this method will return a code that will go from 100 to 600 like if it was a http request. :::spoiler ```cpp int singLullaby(int song, int pin) ``` ::: Define a function called singLullaby that is going to tone a lullaby when called from a number of possible lullaby songs. The number of the song has to be provided, also the pin where the buzzer is set. Since singing is difficult, this method will return true if has achieved to sing the full lullaby and false if there was any kind of error during execution. :::spoiler ```cpp bool singLullaby(int song, int pin) ``` ::: Define a function called singLullaby that is going to tone a lullaby when called. It will print "song is over" through serial when it finishes playing the song. :::spoiler ```cpp void singLullaby() ``` :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully