#Java CameraBattery
1 messages · Page 1 of 1 (latest)
While you are waiting for getting help, here are some tips to improve your experience:
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.
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
Could you describe the issue?
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
How are you tracking the battery removal in code?
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
Why are you not using boolean?
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
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.
Using bad practices?
I suppose
-_-
They're doing it for practise, using a boolean is the straightforward way here.
I tried doing that and ran the tests but it output the wrong values since it was giving 0 instead of the expected values
You shouldn't do bad code, in particular when it's for practice, because now you are practicing bad code
If you learn something new, the hard part is to know when to use it, here you are doing the reverse @devout junco
It's supposed to subtract the lower value from batteryCharge to prevent it from going below 0
what should I do to not do bad code? It's a requirement that I'm not allowed to use booleans and conditionals
Ah it's an assignment?
Yeah it's annoying but I have to work with what I got
Booleans are my last absolute option
Rip
rip indeed
that's why I was hoping to get some tips on how to move forward to get the code done by today
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
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
https://hastebin.com/share/loxonajuke.csharp - updated code
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
issue
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
what methods are you calling and for what input?
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
Yea because it's charging it with the min value of your ChargeCapacity
Math.min(ChargeCapacity, Charging); still will give a non zero value which will get added to CameraCharge
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 👍