NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public class Zaman1
{
private int saat; //0-23
private int dakika; //0-59
private int saniye; //0-59

public void setZaman(int saat, int dakika, int saniye)
{
if ((saat>=0 && saat<24) && (dakika>=0 && dakika<60) &&
(saniye>=0 && saniye<60))
{
this.saat=saat;
this.dakika=dakika;
this.saniye=saniye;
}
else

throw new IllegalArgumentException("saat/dakika/saniye aralık dışı");
}
public String toEvrenselString()
{
return String.format("%02d:%02d:%02d",saat,dakika,saniye);
}

public String toString()
{
return String.format("%d:%02d:%02d %s",((saat==0 || saat==12) ?12:saat%12),
dakika,saniye,(saat<12 ? "AM": "PM"));

}

}

public class Zaman1Test
{
public static void main(String[] args)
{
Zaman1 zaman1=new Zaman1();
System.out.print("İlk evrensel saat:");
System.out.println(zaman1.toEvrenselString());
System.out.print("İlk standart saat:");
System.out.println(zaman1.toString());
zaman1.setZaman(13,27,6);
System.out.print("Yeni evrensel saat:");
System.out.println(zaman1.toEvrenselString());
System.out.print("Yeni standart saat:");
System.out.println(zaman1.toString());

try
{
zaman1.setZaman(99,99,99);
}
catch (IllegalArgumentException e)
{
System.out.println("Yanlış zaman ayarından sonra");
System.out.print("Evrensel zaman:");
System.out.println(zaman1.toEvrenselString());
System.out.print("Standart zaman:");
System.out.println(zaman1.toString());
}


}


}

public class ZamanErisimTest
{
public static void main(String[] args)
{
Zaman1 zaman1=new Zaman1();

zaman1.saat=7;
zaman1.dakika=15;
zaman1.saniye=30;

}
}

public class ThisTesti
{
public static void main(String[] args)
{
BasitZaman zaman=new BasitZaman(15,30,19);
System.out.println(zaman.StringInsaEt());
}
}

class BasitZaman
{

private int saat; //0-23
private int dakika; //0-59
private int saniye; //0-59

public BasitZaman(int saat, int dakika, int saniye)
{
this.saat=saat;
this.dakika=dakika;
this.saniye=saniye;
}

public String StringInsaEt()
{
return String.format("%24s: %sn%24s: %s",
"this.toEvrenselString()",this.toEvrenselString(),
"toEvrenselString)=",toEvrenselString());
}

public String toEvrenselString()
{
return String.format("%02d:%02d:%02d",this.saat,this.dakika,this.saniye);

}

}

public class ThisTesti
{
public static void main(String[] args)
{
BasitZaman zaman=new BasitZaman(15,30,19);
System.out.println(zaman.StringInsaEt());
}
}

class BasitZaman
{

private int saat; //0-23
private int dakika; //0-59
private int saniye; //0-59

public BasitZaman(int saat, int dakika, int saniye)
{
this.saat=saat;
this.dakika=dakika;
this.saniye=saniye;
}

public String StringInsaEt()
{
return String.format("%24s: %sn%24s: %s",
"this.toEvrenselString()",this.toEvrenselString(),
"toEvrenselString)=",toEvrenselString());
}

public String toEvrenselString()
{
return String.format("%02d:%02d:%02d",this.saat,this.dakika,this.saniye);

}

}

public class Zaman2
{
private int saat; //0-23
private int dakika; //0-59
private int saniye; //0-59

public Zaman2()
{
this(0,0,0);
}

public Zaman2(int h)
{
this(h,0,0);
}

public Zaman2(int h, int m)
{
this(h,m,0);
}

public Zaman2(int h, int m, int s)
{
setZaman(h,m,s);
}

public Zaman2(Zaman2 zaman2)
{
this(zaman2.getSaat(),zaman2.getDakika(),zaman2.getSaniye());
}

public void setZaman(int h, int m, int s)
{
setSaat(h);
setDakika(m);
setSaniye(s);
}

public void setSaat(int h)
{
if (h>=0 && h<24)
saat=h;
else
throw new IllegalArgumentException ("Saat 0-23 arası olmalı!");
}

public void setDakika(int m)
{
if (m>=0 && m<60)
dakika=m;
else
throw new IllegalArgumentException ("Dakika 0-59 arası olmalı!");
}

public void setSaniye(int s)
{
if (s>=0 && s<60)
saniye=s;
else
throw new IllegalArgumentException ("Saniye 0-59 arası olmalı!");
}

public int getSaat()
{
return saat;
}

public int getDakika()
{
return dakika;
}

public int getSaniye()
{
return saniye;
}

public String toEvrenselString()
{
return String.format("%02d:%02d:%02d",saat,dakika,saniye);
}

public String toString()
{
return String.format("%d:%02d:%02d %s",((saat==0 || saat==12) ?12:saat%12),
dakika,saniye,(saat<12 ? "AM": "PM"));

}

}

public class Zaman2Test
{
public static void main(String[] args)
{
Zaman2 z1=new Zaman2();
Zaman2 z2=new Zaman2(2);
Zaman2 z3=new Zaman2(21,34);
Zaman2 z4=new Zaman2(12,25,42);
Zaman2 z5=new Zaman2(z4);

System.out.println("z1: tüm parametreler default");
System.out.printf(" %sn",z1.toEvrenselString());
System.out.printf(" %sn",z1.toString());

System.out.println("z2: sadece saat parametresi var");
System.out.printf(" %sn",z2.toEvrenselString());
System.out.printf(" %sn",z2.toString());


System.out.println("z3: sadece saat ve dakika parametresi var");
System.out.printf(" %sn",z3.toEvrenselString());
System.out.printf(" %sn",z3.toString());

System.out.println("z4: tüm parametresi var");
System.out.printf(" %sn",z4.toEvrenselString());
System.out.printf(" %sn",z4.toString());

System.out.println("z5: sadece saat ve dakika parametresi var");
System.out.printf(" %sn",z5.toEvrenselString());
System.out.printf(" %sn",z5.toString());

}


}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.