Religious Studies  >  SOPHIA Milestone  >  College of William & Mary - CS 1114 TurtleTest.java (All)

College of William & Mary - CS 1114 TurtleTest.java

Document Content and Description Below

College of William & Mary - CS 1114TurtleTest.java import sofia.micro.*; import sofia.util.Random; // ------------------------------------------------------------------------- public class TurtleT ... est extends TestCase { //~ Fields ................................................................ private Beach beach; private Turtle turtle; //~ Constructor ........................................................... // ---------------------------------------------------------- /** * Creates a new TurtleTest test object. */ public TurtleTest() { . } //~ Methods ............................................................... // ---------------------------------------------------------- /** * Sets up the test fixture. * Called before every test case method. */ public void setUp() { beach = new Beach(); turtle = new Turtle(); } // ---------------------------------------------------------- /*# Insert your own test methods here */ /** * tests that there is no turtle in the world. * first constructor */ public void testBeach() { assertEquals(0, beach.getObjects(Turtle.class).size()); } public void testBeach2() { beach = new Beach(5); assertEquals(5, beach.getObjects(Turtle.class).size()); } /** * tests that there are 0 turtles in the world */ public void testAddTurtle() { assertEquals(0, beach.getObjects(Turtle.class).size()); https://www.coursehero.com/file/57231150/TurtleTestjava/ This study resource was shared via CourseHero.com} /** * tets that the turtle turns right. */ public void testRandomTurn() { beach.add(turtle, 1, 1); Random.generator().setNextBooleans(true); turtle.randomTurn(); turtle.move(); //assertEquals(turtle.getDirection(), SOUTH); assertEquals(2, turtle.getGridY()); } public void testRandomTurn2() { beach.add(turtle, 1, 1); Random.generator().setNextBooleans(false); turtle.randomTurn(); turtle.move(); //assertEquals(turtle.getDirection(), SOUTH); assertEquals(0, turtle.getGridY()); } /** * tests that the turtle and the marker are at same location. */ public void testMove() { Marker marker = new Marker(); assertEquals(marker.getGridX(), turtle.getGridX()); assertEquals(marker.getGridY(), turtle.getGridY()); } /** * tests that the turtle moves 5 times * second move method. */ public void testMove2() { beach.add(turtle, 1, 1); turtle.move(5); assertEquals(6, turtle.getGridX()); } /** * tests that turtle moves randomly between 1 and 4 moves * in this case it moves once. */ public void testAct() { beach.add(turtle, 1, 1); Random.generator().setNextInts(0); This study resource was shared via CourseHero.comturtle.act(); assertEquals(2, turtle.getGridX()); [Show More]

Last updated: 3 years ago

Preview 1 out of 3 pages

Buy Now

Instant download

We Accept:

Payment methods accepted on Scholarfriends (We Accept)
Preview image of College of William & Mary - CS 1114 TurtleTest.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 )

$9.50

Buy Now

We Accept:

Payment methods accepted on Scholarfriends (We Accept)

Instant download

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

114
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 20, 2021

Number of pages

3

Written in

All

Seller


Profile illustration for QuizMaster
QuizMaster

Member since 6 years

1194 Documents Sold

Reviews Received
185
56
29
11
17
Additional information

This document has been written for:

Uploaded

Mar 20, 2021

Downloads

 0

Views

 114

Document Keyword Tags


$9.50
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·