Advertisement
thenewboston

Java Programming Tutorial - 39 - Multiple Constructors

Aug 22nd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public class tuna {
  2.    private int hour;
  3.    private int minute;
  4.    private int second;
  5.    
  6.    public tuna(){
  7.       this(0,0,0);
  8.    }
  9.    public tuna(int h){
  10.       this(h,0,0);
  11.    }
  12.    public tuna(int h, int m){
  13.       this(h,m,0);
  14.    }
  15.    public tuna(int h, int m, int s){
  16.       setTime(h,m,s);
  17.    }
  18.    public void setTime(int h, int m, int s){
  19.       setHour(h);
  20.       setMinute(m);
  21.       setSecond(s);
  22.    }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement