Hello I try to solve exam task can you help me please my code condition: https://pastebin.com/rYg28C
53 Replies
... a zip?
yea there are lots of classes
Can you at least put a little more effort into trying to cheat on an exam task?
github link, describe where you are having trouble etc
What do you talk i dont try to cheat
My exam is next mounth
also your link has expired :p
he is talking about no one here downloads unknown compressed files from strangers its a red flag.
Please use the $paste website below or github to share your code
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
the above site can hold many classes
and github can hold whole solutions
All I know is what you've written. You said "exam task". How should I know that its practice for an exam next month, if you dont say it?
that is the preferred way of sharing code
now i will do it
GitHub
GitHub - vankata06/Nautical-Catch-Challenge
Contribute to vankata06/Nautical-Catch-Challenge development by creating an account on GitHub.
Is now good?
Good. Now fix the link to the task description, and say exactly what you need help with
How to do the task link?
again github or
word
as a markdown file on the github repo would be great
GitHub
GitHub - vankata06/Nautical-Catch-Challenge
Contribute to vankata06/Nautical-Catch-Challenge development by creating an account on GitHub.
like that
I am in the Diver class now and I am not sure how to implement the methods
okay
I almost do the Hit methods but the second condition is hard for me
The Name of the caught Fish is added to the diver's Catch list.
Cath is IReadOnlyCollection and dont know how to add item inside
Ah, see, they've been a bit tricky
The interface contains...
IReadOnlyCollection<string> Catch { get; }
that means you must have a property with a public getter with this typeToo the condition says that Miss and RenewOxy are abstact methods and i dont know do I have to implement the in this class
it doesnt mean you cant source that list from another place
abstract methods have no bodies
Ok I have it but again cant use Add
you just gotta be smart 🙂
And to add catches in constructor maybe
we can expose a readonly version of a normal list like this
i was thinking for this
but was not sure
why would you add it to the constructor?
I'd either add a protected
AddCatch
method or make the entire list protected
thou
so that inheriting classes can use itOk i understand
but how to get • The Name of the caught Fish
maybe with GetType?
.. no
IFish
has a Name
property
just use thataha okk
and last is UpdateHealthStatus method
This method changes the health status of the diver to True, if it is False or reciprocally
health status is false on default
so
so it toggles the health status
true to false, false to true
thats an easy oneliner
I dont understand
public void UpdateHealthStatus()
{
HasHealthIssues = false;
HasHealthIssues = true;
}
or onlu true?
without false
no, you're supposed to toggle it
set it to true if it was false, and false if it was true
public void UpdateHealthStatus() => HasHealthIssues = !HasHealthIssues;
does exactly that 🙂aha i undrstand thanks
i and think in the ovveride method
public override string ToString()
{
return $"Diver [ Name: {Name}, Oxygen left: {OxygenLevel}, Fish caught: {catches.Count}, Points earned: {CompetitionPoints} ]";
}
is like that
catches.Count
something like that, sure
ok thanks
I hope that the class is correct now
But now i have problem with FreeDiver
Condition: It has OxygenLevel value of 120 seconds.
FreeDiver will decrease the OxygenLevel property by 60% (using the Miss() method) of the TimeToCatch value of the missed fish.
• If the calculated value is not a whole number, round it to the nearest whole integer.
The Constructor of the FreeDiver should take the following parameters upon initialization:
i write const for oxygen level
but how to increase the property
how to use it
maybe i need list<Diver> or?
.. what?
void Miss(int timeToCatch) The Miss() is an abstract method that should decrease the diver's OxygenLevel property. When the method is invoked the diver's OxygenLevel is decreased by a certain value, that will depend on the fish that is chased. OxygenLevel -= (int)Math.Round(…, MidpointRounding.AwayFromZero);
that conditiuon is down
in child class
FreeDiver is child class
And i dont know how to use the property from diver
you just use it
give exeption
idk why
its not from the private set
well, it is
make it
protected
also, your setter doesnt really do what it should
if a value that is below 0 is entered, it should set it to 0yea i see this and done it
but now i forgot how to solve this:D
maybe cast or
your problem description already tells you
OxygenLevel -= (int)Math.Round(…, MidpointRounding.AwayFromZero);
yea now works
and last is RenewOxy method
It should be abstract method. The diver's OxygenLevel should be fully replenished to its original or maximum value. This would mean setting the OxygenLevel back to its starting value depending on the diver’s type
here i cant understand what to do
really?
just have each diver type keep track of its own original value
aha
ok ready
thanks