{
  "format": "tokbit",
  "version": 1,
  "name": "Kolik ti je let a plnoletost",
  "main": [
    {
      "id": "u1",
      "kind": "declare",
      "name": "den",
      "type": "int"
    },
    {
      "id": "u2",
      "kind": "declare",
      "name": "mesic",
      "type": "int"
    },
    {
      "id": "u3",
      "kind": "declare",
      "name": "rok",
      "type": "int"
    },
    {
      "id": "u4",
      "kind": "doWhile",
      "body": [
        {
          "id": "u5",
          "kind": "input",
          "target": "den",
          "prompt": "Den narození (1–31):"
        },
        {
          "id": "u6",
          "kind": "if",
          "condition": "den < 1 or den > 31",
          "then": [
            {
              "id": "u7",
              "kind": "output",
              "values": "\"Den musí být od 1 do 31.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "den < 1 or den > 31",
      "comment": "Ptá se znovu, dokud den nedává smysl."
    },
    {
      "id": "u8",
      "kind": "doWhile",
      "body": [
        {
          "id": "u9",
          "kind": "input",
          "target": "mesic",
          "prompt": "Měsíc narození (1–12):"
        },
        {
          "id": "u10",
          "kind": "if",
          "condition": "mesic < 1 or mesic > 12",
          "then": [
            {
              "id": "u11",
              "kind": "output",
              "values": "\"Měsíc musí být od 1 do 12.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "mesic < 1 or mesic > 12"
    },
    {
      "id": "u12",
      "kind": "doWhile",
      "body": [
        {
          "id": "u13",
          "kind": "input",
          "target": "rok",
          "prompt": "Rok narození:"
        },
        {
          "id": "u14",
          "kind": "if",
          "condition": "rok > year()",
          "then": [
            {
              "id": "u15",
              "kind": "output",
              "values": "\"Rok nemůže být v budoucnosti.\""
            }
          ],
          "else": []
        }
      ],
      "condition": "rok > year()"
    },
    {
      "id": "u16",
      "kind": "declare",
      "name": "vek",
      "type": "int",
      "init": "year() - rok",
      "comment": "Věk podle letopočtu; year() je letošní rok."
    },
    {
      "id": "u17",
      "kind": "if",
      "condition": "month() < mesic or (month() == mesic and day() < den)",
      "then": [
        {
          "id": "u18",
          "kind": "assign",
          "target": "vek",
          "value": "vek - 1"
        }
      ],
      "else": [],
      "comment": "Letos ještě narozeniny nebyly: o rok míň."
    },
    {
      "id": "u19",
      "kind": "if",
      "condition": "vek == 1",
      "then": [
        {
          "id": "u20",
          "kind": "output",
          "values": "\"Je ti\", vek, \"rok.\""
        }
      ],
      "else": [
        {
          "id": "u21",
          "kind": "if",
          "condition": "vek >= 2 and vek <= 4",
          "then": [
            {
              "id": "u22",
              "kind": "output",
              "values": "\"Je ti\", vek, \"roky.\""
            }
          ],
          "else": [
            {
              "id": "u23",
              "kind": "output",
              "values": "\"Je ti\", vek, \"let.\""
            }
          ]
        }
      ],
      "comment": "Česky 1 rok, 2–4 roky, jinak let."
    },
    {
      "id": "u24",
      "kind": "if",
      "condition": "vek >= 18",
      "then": [
        {
          "id": "u25",
          "kind": "output",
          "values": "\"Jsi plnoletý.\""
        }
      ],
      "else": [
        {
          "id": "u26",
          "kind": "output",
          "values": "\"Plnoletý budeš v roce\", rok + 18"
        }
      ]
    },
    {
      "id": "u27",
      "kind": "if",
      "condition": "month() == mesic and day() == den",
      "then": [
        {
          "id": "u28",
          "kind": "output",
          "values": "\"Všechno nejlepší k narozeninám!\""
        },
        {
          "id": "u29",
          "kind": "call",
          "call": "note(\"C5\", 200)"
        },
        {
          "id": "u30",
          "kind": "call",
          "call": "note(\"E5\", 200)"
        },
        {
          "id": "u31",
          "kind": "call",
          "call": "note(\"G5\", 200)"
        },
        {
          "id": "u32",
          "kind": "call",
          "call": "note(\"C6\", 400)"
        }
      ],
      "else": [],
      "comment": "Dnes má narozeniny: přání a melodie."
    }
  ],
  "functions": [],
  "comment": "Řešení úlohy „Plnoletost“: Program dopíše, jestli je člověk plnoletý, a když ne, v kterém roce mu bude 18.",
  "screen": "fit"
}
