Liutauras Vilda wrote:And welcome to the Ranch
![]()
And something right from the beginning doesn't look ok with this code (for quite few reasons). But first, lets wait your answer to the question above.
Alright. That is a very minimalistic information we could give some help on. In different words - we don't know what the instructions are. Either we need those, or we need to know what exact difficulties you're having with your code (regardless what kind of instructions are).dan kom wrote:Yes it is homework we are need to do.2 constructors , 3 getMethods and 5 setMethods, all regarding dates.
Liutauras Vilda wrote:
Alright. That is a very minimalistic information we could give some help on. In different words - we don't know what the instructions are. Either we need those, or we need to know what exact difficulties you're having with your code (regardless what kind of instructions are).dan kom wrote:Yes it is homework we are need to do.2 constructors , 3 getMethods and 5 setMethods, all regarding dates.
1. Without seeing exact question or instructions - I think you need to get rid off those _______. Think about the other way to distinct variable names.
2. What is the point of the second constructor? Looks like a useless job. Like a date class within another date class (can't find the words to describe what it looks like). "I'll give you one apple so you'd have one to give me".
That is worse than I thought then.dan kom wrote:we are told to use _x for the instance variables
That is the point - to do what? We don't know how to help until you tell us what you have been asked to do. And when you're not sure, you don't write stuff until you are (different from being mistaken).dan kom wrote:not quite sure about the use of the second constructor, we are just at the beginning, so i think they just gave us stuff to do, even thought it doesn't look too practical.
If you catch yourself writing same code again, you stop and make it a method. Without even noticing you write same code again, all your code needs to be in a methods (small), so they would do only one job each.dan kom wrote:now my question is that if i need to copy the entire block of code
Liutauras Vilda wrote:
If you catch yourself writing same code again, you stop and make it a method.
Yes. If you need to validate something - you create a validation method. If your Date needs to be a valid Georgian date, so you create a method to check isValidGeorgianDate(). If you need to check if it is a leap year, you create a method isLeapYear(). If you're allowed or not try to ask your teacher. If you have been told to use '_x' for instance variable, then we don't know what to expect further.dan kom wrote:
Liutauras Vilda wrote:
If you catch yourself writing same code again, you stop and make it a method.
So should i make boolean validDate() method? to check if date i valid then use it ? looks best to me, but i really hope i'm allowed to do that.
Liutauras Vilda wrote:
Yes. If you need to validate something - you create a validation method. If your Date needs to be a valid Georgian date, so you create a method to check isValidGeorgianDate(). If you need to check if it is a leap year, you create a method isLeapYear(). If you're allowed or not try to ask your teacher. If you have been told to use '_x' for instance variable, then we don't know what to expect further.dan kom wrote:
Liutauras Vilda wrote:
If you catch yourself writing same code again, you stop and make it a method.
So should i make boolean validDate() method? to check if date i valid then use it ? looks best to me, but i really hope i'm allowed to do that.
All things are lawful, but not all things are profitable.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |