_giuraemanuel
_giuraemanuel
CC#
Created by _giuraemanuel on 2/9/2023 in #help
❔ Nullability issue
public bool Equals(Money? money)
{
if (money is null)
{
return false;
}

if (ReferenceEquals(this, money))
{
return true;
}

return Currency.CurrencyCode == money.Currency.CurrencyCode && Amount == money.Amount;
}

public override bool Equals(object? obj)
{
return obj is Money money && Equals(money);
}

public override int GetHashCode()
{
int hash = 17;
hash = hash * 23 + Currency.GetHashCode();
hash = hash * 23 + Amount.GetHashCode();
return hash;
}
}
public bool Equals(Money? money)
{
if (money is null)
{
return false;
}

if (ReferenceEquals(this, money))
{
return true;
}

return Currency.CurrencyCode == money.Currency.CurrencyCode && Amount == money.Amount;
}

public override bool Equals(object? obj)
{
return obj is Money money && Equals(money);
}

public override int GetHashCode()
{
int hash = 17;
hash = hash * 23 + Currency.GetHashCode();
hash = hash * 23 + Amount.GetHashCode();
return hash;
}
}
Sorry for the late reply. Here you go. Based on this: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/how-to-define-value-equality-for-a-type
15 replies
CC#
Created by _giuraemanuel on 2/9/2023 in #help
❔ Nullability issue
Thanks once again!
15 replies
CC#
Created by _giuraemanuel on 2/9/2023 in #help
❔ Nullability issue
Fair enough. I wasn't exactly familiar with equality implementation and stuff so that's why i asked.
15 replies
CC#
Created by _giuraemanuel on 2/9/2023 in #help
❔ Nullability issue
Hmm. Okay. Thank you!
15 replies
CC#
Created by _giuraemanuel on 2/9/2023 in #help
❔ Nullability issue
Hey. Thanks for your answer! But Money can't be null whatsoever so how does that help? Sorry if my question is dumb.
15 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
In truth there are always at least 2 different approaches to solve a problem. Some fit the bill better than others.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
Yes. Chances are good that the course is a sham. You could watch Tim Correy tutorials on YouTube. They are very good for free content. Well explained and easy to grasp. He also has his own website where he sells specialized content. I learned quite a few things from this guy. You can give it a try and see for yourself. Later!
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I've gotta dash. Hit me up in private if you're still having issues. I'll try to point you in the right direction as much as i can. Good luck!
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I'm a junior myself, someone who started this career path on the wrong foot, struggled quite a bit, and i still have some knowledge gaps here and there. But the suggestions i make are the ones i'd try to solve the problem. It's up to you how you want to solve the problem. But for me, it makes sense to use a dictionary. If you're unfamiliar with the structure then read up on it. There are plenty of good sources to get familiar with it. Then im sure you will understand even better why i suggested this approach. It's an option. You decide how to get it done. Two things make a programmer truly great : logical thinking and google searching skills. And you need to practice these skills constantly. Its the only way to grow and get better 🙂
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
int lensesok(field cities, int n, int searchtemp) - for this method another data structure would make more sense. Since you are supposed to return a city based on the temperature. You cannot store both the city and its designated temp inside an array. You need to use a dictionary. I suppose can use array for the first method and a dictionary for the second method tho im not sure it would make more sense.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
^ search for this then try to change your code accordingly
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
No. I mean, use something else than an array. You need to have both the City and it's assigned temperature together. So an array won't cut it here.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I left you a hint, something to work with. Figure out what structure to use then use that instead of your array.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I see. I'm sorry your teacher ain't doing his job like he should.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I'll give you a hint. Key/Value - google for a structure that stores key/value pairs
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I only now noticed it. But since a city needs to have a temperature that means you need to change your array data structure to something else.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
Or maybe not.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
So from what i'm seeing the linear search part looks done to me. I think it's time to move on to the next method.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
but not the arrays and I would prefer practice using them, because I might need use them for career purposes in the future
Fair enough, but most of the time you use lists with foreach or for if you need the index. Tho it's pretty rare to see lists with for. But yes, there's nothing wrong with practicing them. Just a little piece of advice tho. Don't be hellbent on using something just because you like it too much, or you need to practice it. What im saying is, use the appropriate tool. You may prefer idk, arrays over lists, but there are times when a list is 10 times more efficient than a list, for example. It depends on the context. So don't get too attached to something, that's all im saying. It's one thing to do the job but it's an entirely different story to do it right.
143 replies
CC#
Created by The king of kings on 12/21/2022 in #help
❔ Hello everyone, can someone help me out understand this part!
I think it's asking you to have a field that is either an array/list. Since vector is what youd call an array in C# anyway. And that field contains the cities. Then you search for the item you're looking for and if you find it then you return it's position/index
143 replies