#Hint: toString, avg not found in output

1 messages · Page 1 of 1 (latest)

rigid sinew
#

I keep getting an error on toString, avg

sharp zephyrBOT
#

<@&987246964494204979> please have a look, thanks.

rigid sinew
#

Rat.java

#

RatDriver

#

the error

lilac raft
#

So your last testcase is failing. Have you executed your code, and looked at what you're actually getting? Also please share your code as text here, not screenshots.

sharp zephyrBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

rigid sinew
#

@lilac raft imma send it to

sharp zephyrBOT
rigid sinew
#

thats rat.java

low pebble
#

Please format the code as the bot explained and only send relevant code to your issue. Reading that 5 images is a real pain

lilac raft
#

Could you copy the class itself, this one has line numbers.

#

Also have you debugged your output?

rigid sinew
#

I did tried multiple time debugging. I'm in week 2/3 on it of introduction of java . I have rat.java as the first file and RatTest.java as second file that i didn't upload. What do you mean copy the class? like copy the constructor
public class Rat
{
// instance variables

// biometric chip implanted in rat
private String chipRFID;

// number of trials it took rat to establish criterion
private int numTrials;

// total amount of time in seconds for all trials
private int ttlTimeSecs;
#

I don't mind if we go to the VC

#

@lilac raft

lilac raft
#

I'm working on some personal projects, so I don't really have time for VC.

#

If you place a breakpoint, what's the value there? Or just print out the tmpRat toString.

#

And that's not your full code.

rigid sinew
#

@lilac raft /**
146
* Test the getAverageTime() method.
147
*/
148
@Test
149
public void testGetAverageTime()
150
{
151
// Create a new test rat object
152
Rat tmpRat = new Rat("OH1234567", 12, 4685);
153

154
// retrieve the average time for the rat object
155
// test to make sure it is the correct value
156
// replace 0 with correct value below
157
assertEquals((4685.0 / 12.0), tmpRat.getAverageTime(), .01);
158
}
159

160
/**
161
* Test the toString() method.
162
*/
163
@Test
164
public void testToString()
165
{
166
// Create a new test rat object
167
Rat tmpRat = new Rat("OH1234567", 17, 6285);
168

169
// Check to make sure the output contains the chipid
170
assertTrue(tmpRat.toString().contains("OH1234567"));
171

172
// Check to make sure the output contains the trials
173
assertTrue(tmpRat.toString().contains("17"));
174

175
// your code here to test that the hours is in the output
176
assertTrue(tmpRat.toString().contains("1 hour"));
177

178
// your code here to test that the minutes is in the output
179
assertTrue(tmpRat.toString().contains("44 minute"));
180

181
// your code here to test that the seconds is in the output
182
assertTrue(tmpRat.toString().contains("45 second"));
183

184
// your code here to test that the average is in the output
185

186
assertTrue(tmpRat.toString().contains("369.71 seconds"));
187
}
188
}