IB Comp Sci SL - October 18 2016 Lesson Notes

From Computer Science Wiki
Jump to navigation Jump to search

Class plan.png What are we going to learn today?[edit]

  1. Today in class we will apply our understanding of php and arrays as we work on a RPG character creation system
  2. we will revisit conditionals

The HTML form:

<!doctype html>
<html>
<!-- welcome to our simple chargen system -->
<form action="char_gen.php" method="post">
    <p><label>Pay to win:
    <input type="radio" name="paytowin" value="yes">Yes
    <input type="radio" name="paytowin" value="no">No
    </label></p>

    <p>Race:
    <br />
    <br />
    <input type="radio" name="race" value="elf">Elf<br />
    <input type="radio" name="race" value="dwarf">Dwarf<br />
    <input type="radio" name="race" value="human">Human<br />
    <input type="radio" name="race" value="khajit">Khajiit<br />
    <input type="radio" name="race" value="gnome">Gnome<br />
    <input type="radio" name="race" value="centaur">Centaur<br />
    </p>

    <p>Gender:
    <br />
    <br />
    <input type="radio" name="gender" value="male">Male<br />
    <input type="radio" name="gender" value="female">Female<br />
    <input type="radio" name="gender" value="other">Other<br />
    </p>

    <p><input type="submit" value="Onto step 2!" /></p>

</form>
</html>


<?php

$pay_to_win = $_POST['paytowin'];
$race = $_POST['race'];
$gender = $_POST['gender'];

echo "debug: you are passing pay to win = $pay_to_win, race = $race
and gender = $gender";

if ($pay_to_win == "yes")

{

$strength = mt_rand(50,100);
$intelligence = mt_rand(0,50);
$agility = mt_rand(50,100);

}

else

{

$strength = mt_rand(0,100);
$intelligence = mt_rand(0,100);
$agility =mt_rand(0,100);

}


echo "<p>Strength: $strength </p>";
echo "<p>Intelligence: $intelligence </p>";
echo "<p>Agility: $agility </p>";

?>


Homework.png Homework[edit]

  1. Learn and apply sessions to our character generation program


Target.png How am I being assessed today?[edit]

  1. You will be formatively assessed in class today

Ourstandards.png Standards we are covering today[edit]

Computer1.png As a computer scientist, you have:[edit]

  • Confidence in dealing with complexity
  • Persistence in working with difficult problems
  • Tolerance for ambiguity
  • The ability to deal with open-ended problems
  • The ability to communicate and work with others to achieve a common goal or solution

Credit.png Credits[edit]

Use an idea, equation, principle, theory or law in relation to a given problem or issue.

Add labels to a diagram.

Give a detailed account or picture of a situation, event, pattern or process.

Develop information in a diagrammatic or logical form.