Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Carlos Garcia
- L3E1
- Building castles
- */
- package Lesson3;
- import kareltherobot.UrRobot;
- import kareltherobot.World;
- import java.awt.*;
- public class Evaluation1 extends UrRobot {
- public Evaluation1(int street , int avenue , Direction direction , int beeperCount){
- super(street, avenue, direction, beeperCount, Color.PINK);
- }
- public static void main(String[] args) {
- World.setDelay(2);
- World.setVisible();
- World.setBeeperColor(Color.blue);
- World.setSize(25,45);
- World.showSpeedControl(true);
- Evaluation1 TowerBuilder1 = new Evaluation1(1,2,North,-1);
- Evaluation1 TowerBuilder2 = new Evaluation1(1,45,North,-1);
- Evaluation1 RoofBuilder = new Evaluation1(15,16,North,-1);
- Evaluation1 DoorBuilder = new Evaluation1(1,20,North,-1);
- Evaluation1 WindowBuilder1 = new Evaluation1(8,7,East,-1);
- Evaluation1 WindowBuilder2 = new Evaluation1(8,36,East,-1);
- TowerBuilder1.buildTower1();
- TowerBuilder1.setVisible(false);
- TowerBuilder2.buildTower2();
- TowerBuilder2.setVisible(false);
- RoofBuilder.buildRoof();
- RoofBuilder.setVisible(false);
- DoorBuilder.buildDoor();
- DoorBuilder.setVisible(false);
- WindowBuilder1.buildWindow();
- WindowBuilder1.setVisible(false);
- WindowBuilder2.buildWindow();
- WindowBuilder2.setVisible(false);
- }
- /**
- * Function to turn right
- * @return void
- * */
- public void turnRight(){
- World.setDelay(0);
- turnLeft();
- turnLeft();
- turnLeft();
- World.setDelay(2);
- }
- /**
- * Function to build the towers
- * @return void
- * */
- public void buildTower1(){
- for (int i = 0; i < 24; i++) { //loop to go up
- putBeeper();
- move();
- }
- putBeeper();
- for (int i = 0; i < 3; i++) { //upper part of the tower
- turnRight();
- move();
- putBeeper();
- move();
- putBeeper();
- turnRight();
- for (int j = 0; j < 2; j++) {
- move();
- putBeeper();
- move();
- putBeeper();
- if ((i == 0)&&(j==0)) {
- move();
- putBeeper();
- }
- turnLeft();
- }
- move();
- putBeeper();
- move();
- putBeeper();
- if (i == 2) {
- move();
- putBeeper();
- }
- }
- turnRight();
- for (int i = 0; i < 2; i++) { // loop to go back
- move();
- putBeeper();
- }
- turnRight();
- for (int i = 0; i < 10; i++) {
- move();
- putBeeper();
- }
- }
- /**
- * Function to build the other tower
- * @return void
- * */
- public void buildTower2(){
- for (int i = 0; i < 24; i++) { //loop to go uo
- putBeeper();
- move();
- }
- putBeeper();
- for (int i = 0; i < 3; i++) { //upper part of the tower
- turnLeft();
- move();
- putBeeper();
- move();
- putBeeper();
- turnLeft();
- for (int j = 0; j < 2; j++) {
- move();
- putBeeper();
- move();
- putBeeper();
- if ((i == 0)&&(j==0)) {
- move();
- putBeeper();
- }
- turnRight();
- }
- move();
- putBeeper();
- move();
- putBeeper();
- if (i == 2) {
- move();
- putBeeper();
- }
- }
- turnLeft();
- for (int i = 0; i < 2; i++) { //loop to go back
- move();
- putBeeper();
- }
- turnLeft();
- for (int i = 0; i < 10; i++) {
- move();
- putBeeper();
- }
- }
- /**
- * Function to build the roof
- * @return void
- * */
- public void buildRoof(){
- turnRight();
- move();
- putBeeper();
- for (int i = 0; i < 6; i++) { //loop to make the ascending part
- turnLeft();
- move();
- turnRight();
- move();
- putBeeper();
- }
- move();
- putBeeper();
- for (int i = 0; i < 6; i++) { //loop to make the descending part
- turnRight();
- move();
- turnLeft();
- move();
- putBeeper();
- }
- }
- /**
- * Function to build a door
- * @return void
- * */
- public void buildDoor(){
- for (int i = 0; i < 8; i++) {
- putBeeper();
- move();
- if (i==2){
- turnRight();
- move();
- putBeeper();
- turnLeft();
- turnLeft();
- move();
- turnRight();
- }
- }
- putBeeper();
- turnRight();
- for (int i = 0; i < 7; i++) {
- move();
- putBeeper();
- }
- turnRight();
- for (int i = 0; i < 8; i++) {
- move();
- putBeeper();
- }
- }
- /**
- * Function to build thw windows
- * @return void
- * */
- public void buildWindow(){
- for (int i = 0; i < 4; i++) {
- putBeeper();
- move();
- }
- turnLeft();
- for (int i = 0; i < 7; i++) {
- putBeeper();
- move();
- }
- putBeeper();
- for (int i = 0; i < 2; i++) {
- turnLeft();
- move();
- turnRight();
- move();
- putBeeper();
- }
- turnLeft();
- for (int i = 0; i < 2; i++) {
- turnLeft();
- move();
- turnRight();
- move();
- putBeeper();
- }
- turnLeft();
- for (int i = 0; i < 6; i++) {
- move();
- putBeeper();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement