Changes between Version 1 and Version 2 of ControlSystems/SoftwareTeam/Training/VirtualTraining/JuniorRobot
- Timestamp:
- Aug 31, 2020, 11:41:55 PM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ControlSystems/SoftwareTeam/Training/VirtualTraining/JuniorRobot
v1 v2 1 1 == Junior Robot == 2 In the last lesson, we tested a basic "Junior Robot" that was created for us. In this lesson, we'll examine the structure of that robot. This lesson will touch lightly on many topics that we will explore in detail in subsequent lessons. Don't expect to understand everything in detail yet; it will become clear over time.2 In the last lesson, we created and tested a basic "Junior Robot". In this lesson, we'll examine the structure of that robot. This lesson will touch lightly on many topics that we will explore in detail in subsequent lessons. Don't expect to understand everything in detail yet; it will become clear over time. 3 3 4 4 === Packages === … … 7 7 }}} 8 8 In Java, related things are grouped together into ''packages''. 9 Examples of related things include: all the robots written by Alice or all the robots written by team 2537 or a set of software tools to make robots (like robocode). Keeping related things in separate packages helps prevent "naming conflicts"; team2537 and team5945 could both create robots named !RoboJojo and battle them without confusion or conflict; they would be referred to as team2537. RoboJojo and team5945.RoboJojo. You can read more about Java packages [https://www.tutorialspoint.com/java/java_packages.htm here]9 Examples of related things include: all the robots written by Alice or all the robots written by team 2537 or a set of software tools to make robots (like robocode). Keeping related things in separate packages helps prevent "naming conflicts"; team2537 and team5945 could both create robots named !RoboJojo and battle them without confusion or conflict; they would be referred to as team2537.!RoboJojo and team5945.!RoboJojo. You can read more about Java packages [https://www.tutorialspoint.com/java/java_packages.htm here] 10 10 11 11 A large part of software development is focused on modularity: keeping related things together '''cohesion''' and avoiding unwanted interactions '''coupling'''. These concepts underpin much of modern software engineering, keep them in mind as you learn to program. Packages are an example of how Java helps encourage cohesion and reduce coupling. … … 27 27 */ 28 28 }}} 29 In the sample program, a comment is provided to show you where to learn more about robocode and the [https://robocode.sourceforge.io/docs/robocode/robocode/JuniorRobot.html !JuniorRobot] followed by a comment that provides the name of your robot, the author, and typically you'd provide a brief summary of what your robot does.29 In the sample program, a comment is provided to show you where to learn more about robocode and the [https://robocode.sourceforge.io/docs/robocode/robocode/JuniorRobot.html JuniorRobot] followed by a comment that provides the name of your robot, the author, and typically you'd provide a brief summary of what your robot does. 30 30 {{{ 31 31 // API help : https://robocode.sourceforge.io/docs/robocode/robocode/JuniorRobot.html … … 45 45 46 46 === Methods === 47 Methods are the verbs of a programming language; the describe the behaviorsof your robot.47 Methods are the verbs of a programming language; they describe the behaviors (actions) of your robot. 48 48 49 49 Every robocode robot must have a '''run''' method that defines what the robot will do when it enters the arena and the battle begins. It is good practice to always place a comment at the start of each method that explains what the method does. For now, just know that you invoke a verb by placing parentheses after it that may include relevant values; for example, to turn the robot 90-degrees to the right you would invoke the method: {{{ turnRight(90); }}} Notice too that a semicolon finishes each invoked method.