Programming > STUDY GUIDE > Virginia Tech - CS 1114Marble.java (All)

Virginia Tech - CS 1114Marble.java

Document Content and Description Below

import sofia.micro.*; import java.util.List; import java.util.ArrayList; //------------------------------------------------------------------------- /** * This is the marble class * * @author E... mily Ashburn (emily2000) * @version (2019.04.04) */ public class Marble extends Actor { //~ Fields ................................................................ private Marble melvin; //~ Constructor ........................................................... // ---------------------------------------------------------- /** * Creates a new Marble object. */ public Marble() { // Do NOT try to calculate the list of friends here, // the marble is not added to a world yet, so it has // no neighbors. } //~ Methods ............................................................... // ---------------------------------------------------------- /** * Finds the marble at the specified height (which could be * at any x-coordinate for that height). * @param yPosition The y-coordinate where the marble is located. * @return The marble with the specified y-coordinate. */ public Marble getMarbleAtHeight(int yPosition) { for (int i = 0; i < this.getWorld().getWidth(); i++) { melvin = this.getWorld().getOneObjectAt(i, yPosition, Marble.class); if (melvin != null) { return melvin; } } return null; } // ---------------------------------------------------------- /** * Get a list of the marbles within two rows on either side * of this marble, not including this marble itself. * @return A list of the marbles with y-coordinates 1 or 2 * cells above or below this marble, not including * this marble. */ public List<Marble> getFriends() { List<Marble> marbleList = new ArrayList<Marble>(); for (int j = this.getGridY() - 2; j <= this.getGridY() + 2; j++) { [Show More]

Last updated: 1 year ago

Preview 1 out of 2 pages

Add to cart

Instant download

document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

Reviews( 0 )

$7.00

Add to cart

Instant download

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

OR

REQUEST DOCUMENT
100
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 24, 2021

Number of pages

2

Written in

Seller


seller-icon
Muchiri

Member since 3 years

208 Documents Sold


Additional information

This document has been written for:

Uploaded

Mar 24, 2021

Downloads

 0

Views

 100

Document Keyword Tags

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·