#Java CameraBattery

1 messages · Page 1 of 1 (latest)

swift basaltBOT
#

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

swift basaltBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

devout junco
#

I'm mostly having issues with test 7 and 8 where the battery is removed from the camera so no need to worry about the tests past that as those are methods that aren't done yet since I'm stuck on this one

devout junco
#

Sorry I just woken up

#

The tests I keep failing are specifically for when the battery is removed which means that the cameraCharge should not be changed while the BatteryCharge still has its value from when it was connected to the camera

elder fjord
#

How are you tracking the battery removal in code?

devout junco
#

Without being able to use conditionals I was hoping I could use 1 and 0 as a way for true or false but I haven’t gotten anywhere with that so I was hoping I could get some tips on how to move forward

#

I was going to use Math.min and Math.max to switch between 1 and 0

livid tinsel
devout junco
#

It’s a requirement to help myself understand what I learned so far rather than using an easy way I was trying things in a challenging way

elder fjord
#

You could set BatteryCharge=0

#

This would fix the drain() function

#

Drain = Math.min(Drain, BatteryCharge);
would be 0

#

A minor change in cameraCharge( might also be required.

devout junco
#

Alright I’ll try that and let you know how it goes

#

Thank you

devout junco
#

I suppose

livid tinsel
#

-_-

elder fjord
#

They're doing it for practise, using a boolean is the straightforward way here.

devout junco
livid tinsel
devout junco
#

It's supposed to subtract the lower value from batteryCharge to prevent it from going below 0

devout junco
devout junco
#

Yeah it's annoying but I have to work with what I got

#

Booleans are my last absolute option

livid tinsel
#

Rip

devout junco
#

rip indeed

#

that's why I was hoping to get some tips on how to move forward to get the code done by today

digital acorn
#

U could use bitwise operations on 0s and 1s

#

They would return work just like boolean

#

Except for ~ ig, you would have to do +2 afterwards

devout junco
#

so I gave up and started using booleans and conditionals

#

and I'm trying to figure out why the output is 1000 more than the expected in my specchecker

devout junco
#

I assume it's the charge method with the if conditions and I don't know why it's adding past the max capacity limit

dense pebble
#

what methods are you calling and for what input?

devout junco
#

First it inputs the parameters of BatteryCharge and ChargeCapacity through the constructor.
From there it's calling the moveBatteryCamera method which sets up the battery in the camera

#

Lastly it calls the cameraCharge method to add charge which in this case should go from 1000 to 1500 which is the limit for the parameters

elder fjord
#

Math.min(ChargeCapacity, Charging); still will give a non zero value which will get added to CameraCharge

swift basaltBOT
#

Closed the thread due to inactivity.

If your question was not resolved yet, feel free to just post a message to reopen it, or create a new thread. But try to improve the quality of your question to make it easier to help you 👍