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

Preview 1 out of 3 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 )

$9.50

Buy Now

We Accept:

We Accept

Instant download

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

99
0

Document information


Connected school, study & course


About the document


Uploaded On

Mar 20, 2021

Number of pages

3

Written in

Seller


seller-icon
QuizMaster

Member since 6 years

1187 Documents Sold

Reviews Received
185
56
29
11
17
Additional information

This document has been written for:

Uploaded

Mar 20, 2021

Downloads

 0

Views

 99

Document Keyword Tags


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