{
  "format": "tokbit",
  "version": 1,
  "name": "Věk ve dnech",
  "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": "output",
      "values": "\"To je asi\", vek * 365, \"dní.\"",
      "comment": "Odhad: přestupné roky a dny od posledních narozenin nepočítá."
    },
    {
      "id": "u25",
      "kind": "if",
      "condition": "month() == mesic and day() == den",
      "then": [
        {
          "id": "u26",
          "kind": "output",
          "values": "\"Všechno nejlepší k narozeninám!\""
        },
        {
          "id": "u27",
          "kind": "call",
          "call": "note(\"C5\", 200)"
        },
        {
          "id": "u28",
          "kind": "call",
          "call": "note(\"E5\", 200)"
        },
        {
          "id": "u29",
          "kind": "call",
          "call": "note(\"G5\", 200)"
        },
        {
          "id": "u30",
          "kind": "call",
          "call": "note(\"C6\", 400)"
        }
      ],
      "else": [],
      "comment": "Dnes má narozeniny: přání a melodie."
    }
  ],
  "functions": [],
  "comment": "Řešení úlohy „Věk ve dnech“: Odhadni, kolik dní už žiješ: věk · 365. Proč je to jen odhad?",
  "screen": "fit"
}
