Changes between Version 5 and Version 6 of ControlSystems/SoftwareTeam/Training/VirtualTraining/JuniorRobot


Ignore:
Timestamp:
Aug 31, 2020, 11:51:31 PM (5 years ago)
Author:
David Albert
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ControlSystems/SoftwareTeam/Training/VirtualTraining/JuniorRobot

    v5 v6  
    3737
    3838=== Classes ===
    39 We're going to cover classes in much more detail later, but most things in Java programs are either a class or a part of a class.  When you create a type of robot, you create a class and give it a name (e.g. !RoboJojo).  That class can be based on (extend) another class (e.g. !JuniorRobot).   You must indicate whether your class can be imported and used in other packages (e.g. is public).  Finally, everything you want to be in  your class is placed inside a pair of curly braces: {   }
     39We're going to cover classes in much more detail later, but most things in Java programs are either a class or a part of a class.  When you define a new type of robot, you create a class and give it a name (e.g. !RoboJojo).  That class can be based on (extend) another class (e.g. !JuniorRobot).   When a class is based on another class, it inherits all of the behaviors and attributes of that class and extends them with new behaviors and attributes.  You must indicate whether your class can be imported and used in other packages (e.g. is public).  Finally, everything that is part of your class must be placed inside a pair of curly braces: {   }
    4040
    4141{{{
     
    4343{
    4444}}}
     45
     46You can read more about Java classes [https://www.tutorialspoint.com/java/java_object_classes.htm here]
    4547
    4648=== Methods ===
     
    6466}}}
    6567
     68You can read more about Java methods [https://www.tutorialspoint.com/java/java_methods.htm here]
     69
    6670=== Loops ===
    6771One of the nice things about programs is that they can do things repetitively without you having to write the same instructions (methods) over and over.  Once your robocode robot starts running in the battle arena, you want it to keep running until the battle is over so it should continue doing its behaviors indefinitely.  In Java, one of the repetition methods is '''while''' which will repeatedly execute some set of methods (specified inside the curly braces) until some condition (specified inside the parentheses) is false.  Since we want the robot to keep doing its thing indefinitely, we use the while(true) syntax which will repeat forever.  In this case, the robot moves forward 100 spaces, turns in a full circle, then moves back 100 spaces and turns in a full circle.  It will keep doing this forever.
     
    7680                }
    7781}}}
     82
     83You can read more about Java while loops [https://www.tutorialspoint.com/java/java_while_loop.htm here]
    7884
    7985=== Observers ===
     
    111117}}}
    112118
     119You can read more about Java Observers [https://www.baeldung.com/java-observer-pattern here]
     120
    113121== Exercises ==
    1141221. Run !RoboJojo again and observe how the behaviors of the robot relate to the methods.