Computer Science > Research Paper > Rocket.java (All)

Rocket.java

Document Content and Description Below

import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Rocket here. * * @author (your name) * @version (a version number or a date) */ ... public class Rocket extends Actor { /** * Act - do whatever the Rocket wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ private boolean east = true; public void act() { // Add your action code here. if(canMove() == true && east == true) { moveEast(); } else if(canMove() == true && east != true) { moveWest(); } } public void moveEast() { setLocation(getX() + 2, getY()); } public void moveWest() { setLocation(getX() - 2, getY()); } public boolean canMove() { World myWorld = getWorld(); int x = getX(); int y = getY(); if(x >= myWorld.getWidth()-1) { east = false; } else if(x <= 0) { east = true; } [Show More]

Last updated: 2 years ago

Preview 1 out of 2 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$3.00

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

56
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 18, 2021

Number of pages

2

Written in

Seller


seller-icon
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Apr 18, 2021

Downloads

 0

Views

 56

Document Keyword Tags

Recommended For You

Get more on Research Paper »

$3.00
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·