why do we need to create a get method we can use the variable hour and minute and second right away instead of creating a method that returns the variable and then call it ??
So this was uploaded august in 2009 !! Watching it in august 2019!! I like your style of teaching Easy , simple and small topic-wise videos makes learning easy !!
So im lost for the get methods… dont these methods have to take in hour and then return it? If the hour is already there arent you just returning the same thing? In other words whats the point od the get methods I dont get it.
Copied this code multiple times verbatim and it is giving me tons of errors. For some reason eclipse thinks the constructors are methods missing the type… I'm just going to pretend it worked and move on.
If you are using NetBeans (on windows) you can create the variables and press alt + insert, go to "getter and setter" option, select wich variables you want to use and NetBeans will create all the methods itself.
y dont he just public static void Settime(int h,int m,int s){ hour = ((h>=0 && h<24) ? h : 0); minute = ((m>=0 && m<60) ? m : 0); second = ((s>=0 && s<60) ? s : 0); }
when i tried to use c++ i was very confusing to type code, when i am starting to use Java, i have learned a lot of code from them, for my studying Im just made my own management system in simple program as beginner, i was really shocks because that not joke as beginner to build my own system. and then I saw this tutorial in 2017, he show me that the impossible code for statement it could be use in the other way. everyone please not just memorize the code just think about what is impossible to do by code.
Why do you have to create new methods for things like "return hour". For example in the toMilitary method, couldn't you just write hour instead of getHour() and return the function in that way. I am new to Java and it just seems like such a roundabout way of doing things to me. Thanks.
Since it was never really explained, can someone explain to me what returning a variable/value really means? After the variables hour, minute, and second are set, why can't the variables just be called upon? Thanks
one question: since only the last constructor used 'setTime' method, the input format wont be checked for valid if you uses other constructors that only have 'this'. Am I right?
public class tuna { private int hour; private int minute; private int second;
public tuna(){ this(0,0,0); } public tuna(int h){ this(h,0,0); } public tuna(int h, int m){ this(h,m,0); } public tuna(int h, int minute, int s){ setTime(h,m,s); } public void setTime(int h, int minute, int s){ setHour(h); setMinute(m); setSecond(s); } public void setHour(int h){ hour = ((h>=0&&h<24)?h:0); } public void setMinute(int h){ minute = ((m>=0&&m<60)?m:0); } public void setSecond(int h){ second = ((s>=0&&s<60)?s:0); } public int getHour(){ return hour; } public int getMinute(){ return minute; } public int getSecond(){ return second; } public String toMilitary(){ return String.format("%02d:%02d:%02d", getHour(), getMonute(), getSecond()); } }
Watching this in 2020
why do we need to create a get method we can use the variable hour and minute and second right away instead of creating a method that returns the variable and then call it ??
is it poor practice to have user input inside setters ?
So this was uploaded august in 2009 !! Watching it in august 2019!!
I like your style of teaching
Easy , simple and small topic-wise videos makes learning easy !!
So im lost for the get methods… dont these methods have to take in hour and then return it? If the hour is already there arent you just returning the same thing? In other words whats the point od the get methods I dont get it.
What's the purpose of the get methods? Can't I just go straight to toMilitary?
Copied this code multiple times verbatim and it is giving me tons of errors. For some reason eclipse thinks the constructors are methods missing the type… I'm just going to pretend it worked and move on.
your videos have better explanations than my textbook
i advice the beginners to start with c then c++ than java
I always said that the best teacher for new programmers is thenewboston. I wish I could meet him just to shake his glorious hand.
dope
On Eclipse you can generate the getters and setters much faster.
Source -> Generate Getters and Setters
You're welcome
h h
Got. A burning question: could he have not written the get methods, taken out the void in the set method, and put the return in the get methods?
Bucky explained at end of this video what he did. "What the heck we just did here" :)))
return String.format(……….)
Is showing error in Eclipse SDK.
What should i do?
If you are using NetBeans (on windows) you can create the variables and press alt + insert, go to "getter and setter" option, select wich variables you want to use and NetBeans will create all the methods itself.
5:38 lol, right there
when you're setting the hour why don't you write h%24 if the h value isn't in the [0, 24] .
bucky can i do like this…
int sethour(int h)
{
hour = ((h >= 0 && h < 24)? h : 0);
return hour;
}
int setminute(int m)
{
minute = ((m >= 0 && m < 60)? m : 0);
return minute;
}
int setsecond(int s)
{
second = ((s >= 0 && s < 60)? s : 0);
return second;
approximately 1% at school
99% bucky's tut !! lol
This is helping me to much !
y dont he just
public static void Settime(int h,int m,int s){
hour = ((h>=0 && h<24) ? h : 0);
minute = ((m>=0 && m<60) ? m : 0);
second = ((s>=0 && s<60) ? s : 0);
}
when i tried to use c++ i was very confusing to type code, when i am starting to use Java, i have learned a lot of code from them, for my studying Im just made my own management system in simple program as beginner, i was really shocks because that not joke as beginner to build my own system. and then I saw this tutorial in 2017, he show me that the impossible code for statement it could be use in the other way. everyone please not just memorize the code just think about what is impossible to do by code.
Demonetized
Why do you have to create new methods for things like "return hour". For example in the toMilitary method, couldn't you just write hour instead of getHour() and return the function in that way. I am new to Java and it just seems like such a roundabout way of doing things to me. Thanks.
can someone tell some simplest program to understand get and set method.
Since it was never really explained, can someone explain to me what returning a variable/value really means? After the variables hour, minute, and second are set, why can't the variables just be called upon? Thanks
Why can't we just use:
public String toMilitary(){
return String.format("%02d:%02d:%02d", hour(), minute(), second());
}
?
I don't GET this.
GET it because GET method is the subject of this tutorial.
So this must be a tutorial about encapsulation
one question: since only the last constructor used 'setTime' method, the input format wont be checked for valid if you uses other constructors that only have 'this'. Am I right?
package bucky;
public class tuna {
private int hour;
private int minute;
private int second;
public tuna(){
this(0,0,0);
}
public tuna(int h){
this(h,0,0);
}
public tuna(int h, int m){
this(h,m,0);
}
public tuna(int h, int minute, int s){
setTime(h,m,s);
}
public void setTime(int h, int minute, int s){
setHour(h);
setMinute(m);
setSecond(s);
}
public void setHour(int h){
hour = ((h>=0&&h<24)?h:0);
}
public void setMinute(int h){
minute = ((m>=0&&m<60)?m:0);
}
public void setSecond(int h){
second = ((s>=0&&s<60)?s:0);
}
public int getHour(){
return hour;
}
public int getMinute(){
return minute;
}
public int getSecond(){
return second;
}
public String toMilitary(){
return String.format("%02d:%02d:%02d", getHour(), getMonute(), getSecond());
}
}
does not it have a set/get properties like c# ?