[SOLVED] Help me guys :)

0 Ivan M. · June 15, 2014
Hello everyone, I can't solve the problem in this code so would anyone like to help me? I did all the same as Bucky did here -> https://buckysroom.org/videos.php?cat=31&video=18006 

package bucky;class apples {   public static void main(String args[]){  	   tuna tunaObject = new tuna();	   tuna tunaObject2 = new tuna(5);	   tuna tunaObject3 = new tuna(5,13);	   tuna tunaObject4 = new tuna(5,13,43);	   	   System.out.printf("%s", tunaObject.toMilitary());	   System.out.printf("%s", tunaObject2.toMilitary());	   System.out.printf("%s", tunaObject3.toMilitary());	   System.out.printf("%s", tunaObject4.toMilitary());	      }}

<!--?prettify lang=html linenums=true?-->
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 m, int s){  	     setTime(h,m,s);     }         public void seTime(int h, int m, int s){    	setHour(h);    	setMinute(m);    	setSecond(s);    }        public void setHour(int h){    	hour = ((h>=0 && h<24)?h:0);    }    public void setMinute(int m){    	minute = ((m>=0 && m<60)?m:0);    }        public void setSecond(int s){    	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(), getMinute(), getSecond());    }}

And when I run it, it says this:

<!--?prettify lang=html linenums=true?-->
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 	The method setTime(int, int, int) is undefined for the type tuna	at bucky.tuna.(tuna.java:22)	at bucky.tuna.(tuna.java:9)	at bucky.apples.main(apples.java:6)</init>

If anyone can help me, I would be very thankful.

Post a Reply


Oldest  Newest  Rating
0 Ivan M. · June 15, 2014
I should have notice that, but I'm just a beginner. 
Thank you very much!
-1 Pere Garau Burguera · June 15, 2014

public void seTime(int h, int m, int s)

You have a typo on tuna line 25. It says seTime, when it should be setTime
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator