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: 1 year ago

Preview 1 out of 2 pages

Add to cart

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

We Accept:

We Accept

Reviews( 0 )

$3.00

Add to cart

We Accept:

We Accept

Instant download

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

OR

REQUEST DOCUMENT
36
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 3 years

209 Documents Sold


Additional information

This document has been written for:

Uploaded

Apr 18, 2021

Downloads

 0

Views

 36

Document Keyword Tags

Recommended For You

Get more on Research Paper »
What is Browsegrades

In Browsegrades, 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 © Browsegrades · High quality services·