C
C#•3mo ago
vankata06

Hello I try to solve exam task can you help me please my code condition: https://pastebin.com/rYg28C

53 Replies
Pobiega
Pobiega•3mo ago
... a zip?
vankata06
vankata06•3mo ago
yea there are lots of classes
Pobiega
Pobiega•3mo ago
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
vankata06
vankata06•3mo ago
What do you talk i dont try to cheat My exam is next mounth
Pobiega
Pobiega•3mo ago
also your link has expired :p
leowest
leowest•3mo ago
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
MODiX
MODiX•3mo ago
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!
leowest
leowest•3mo ago
the above site can hold many classes and github can hold whole solutions
Pobiega
Pobiega•3mo ago
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?
leowest
leowest•3mo ago
that is the preferred way of sharing code
vankata06
vankata06•3mo ago
now i will do it
vankata06
vankata06•3mo ago
GitHub
GitHub - vankata06/Nautical-Catch-Challenge
Contribute to vankata06/Nautical-Catch-Challenge development by creating an account on GitHub.
vankata06
vankata06•3mo ago
Is now good?
Pobiega
Pobiega•3mo ago
Good. Now fix the link to the task description, and say exactly what you need help with
vankata06
vankata06•3mo ago
How to do the task link? again github or word
Pobiega
Pobiega•3mo ago
as a markdown file on the github repo would be great
vankata06
vankata06•3mo ago
GitHub
GitHub - vankata06/Nautical-Catch-Challenge
Contribute to vankata06/Nautical-Catch-Challenge development by creating an account on GitHub.
vankata06
vankata06•3mo ago
like that I am in the Diver class now and I am not sure how to implement the methods
Pobiega
Pobiega•3mo ago
okay
vankata06
vankata06•3mo ago
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
Pobiega
Pobiega•3mo ago
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 type
vankata06
vankata06•3mo ago
Too the condition says that Miss and RenewOxy are abstact methods and i dont know do I have to implement the in this class
Pobiega
Pobiega•3mo ago
it doesnt mean you cant source that list from another place abstract methods have no bodies
vankata06
vankata06•3mo ago
Ok I have it but again cant use Add
Pobiega
Pobiega•3mo ago
public abstract class Diver : IDiver
{
private List<string> _catches = new();

public IReadOnlyCollection<string> Catch => _catches.AsReadOnly();
}
public abstract class Diver : IDiver
{
private List<string> _catches = new();

public IReadOnlyCollection<string> Catch => _catches.AsReadOnly();
}
you just gotta be smart 🙂
vankata06
vankata06•3mo ago
And to add catches in constructor maybe
Pobiega
Pobiega•3mo ago
we can expose a readonly version of a normal list like this
vankata06
vankata06•3mo ago
i was thinking for this but was not sure
Pobiega
Pobiega•3mo ago
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 it
vankata06
vankata06•3mo ago
Ok i understand but how to get • The Name of the caught Fish maybe with GetType?
Pobiega
Pobiega•3mo ago
.. no IFish has a Name property just use that
vankata06
vankata06•3mo ago
aha 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
Pobiega
Pobiega•3mo ago
so it toggles the health status true to false, false to true thats an easy oneliner
vankata06
vankata06•3mo ago
I dont understand public void UpdateHealthStatus() { HasHealthIssues = false; HasHealthIssues = true; } or onlu true? without false
Pobiega
Pobiega•3mo ago
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 🙂
vankata06
vankata06•3mo ago
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
Pobiega
Pobiega•3mo ago
something like that, sure
vankata06
vankata06•3mo ago
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?
Pobiega
Pobiega•3mo ago
.. 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);
vankata06
vankata06•3mo ago
that conditiuon is down in child class
vankata06
vankata06•3mo ago
No description
vankata06
vankata06•3mo ago
FreeDiver is child class And i dont know how to use the property from diver
Pobiega
Pobiega•3mo ago
you just use it
vankata06
vankata06•3mo ago
No description
vankata06
vankata06•3mo ago
give exeption idk why its not from the private set
Pobiega
Pobiega•3mo ago
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 0
vankata06
vankata06•3mo ago
yea i see this and done it
vankata06
vankata06•3mo ago
but now i forgot how to solve this:D
No description
vankata06
vankata06•3mo ago
maybe cast or
Pobiega
Pobiega•3mo ago
your problem description already tells you OxygenLevel -= (int)Math.Round(…, MidpointRounding.AwayFromZero);
vankata06
vankata06•3mo ago
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
Pobiega
Pobiega•3mo ago
really? just have each diver type keep track of its own original value
vankata06
vankata06•3mo ago
aha ok ready thanks
Want results from more Discord servers?
Add your server
More Posts