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: 3 years ago

Preview 1 out of 2 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of Virginia Tech - CS 1114Marble.java document

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Reviews( 0 )

$7.00

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

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

132
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 24, 2021

Number of pages

2

Written in

All

Seller


Profile illustration for Muchiri
Muchiri

Member since 4 years

209 Documents Sold

Reviews Received
19
5
1
1
6
Additional information

This document has been written for:

Uploaded

Mar 24, 2021

Downloads

 0

Views

 132

Document Keyword Tags

Recommended For You

Get more on STUDY GUIDE »

$7.00
What is Scholarfriends

Scholarfriends.com Online Platform by Browsegrades Inc. 651N South Broad St, Middletown DE. United States.

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·