Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import java.util.Scanner;
public class Deste
{
private Kart[] kartlar = new Kart[52];
private String[] semboller = { "u2660","u2663","u2665","u2666" };
public Deste()
{
int cnt = 0;
for (int i = 0; i<semboller.length; i++)
{
for (int j = 1; j<= 13; j++)
{
kartlar[cnt] = new Kart(semboller[i], j);
cnt++;
}
}
//for (Kart k : kartlar)
//System.out.print(k.print()+";");
}
public void karistir()
{
for (int i = 0; i<100; i++)
{
int i1 = (int)(Math.random() * kartlar.length);
int i2 = (int)(Math.random() * kartlar.length);
Kart tmp = kartlar[i1];
kartlar[i1] = kartlar[i2];
kartlar[i2] = tmp;
}
//for (Kart k : kartlar)
//System.out.print(k.print()+";");
}
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
Deste d = new Deste();
d.karistir();
System.out.println("21 oyununa hos geldiniz : ");
int Odeger = 0 ;
int PcDeger = 0;
boolean oyuncukazandi = false ;
for (int i = 0; i<2; i++)
{
Kart rasgelen = d.kartCek();
System.out.println((i+1)+". Kartiniz : "+ rasgelen.sembol + rasgelen.deger);
if (rasgelen.deger>9) rasgelen.deger=10;
Odeger += rasgelen.deger;
}
System.out.println("Toplam kart degeri : " + Odeger +"n 1- Kart Cek : n 2- Pas");
int Karar = sc.nextInt();
while (Karar<2)
{
Kart rasgelen = d.kartCek();
System.out.println(("Yeni Kartiniz : "+ rasgelen.sembol + rasgelen.deger));
if (rasgelen.deger>9) rasgelen.deger=10;
Odeger += rasgelen.deger;
if (Odeger == 21){oyuncukazandi=true; System.out.println("Toplam kart degeri : " + Odeger + "Kazandiniz"); break;}
if (Odeger >= 21){oyuncukazandi=true; System.out.println("Toplam kart degeri : " + Odeger + "Kaybettiniz PC Kazandi"); break;}
System.out.println("Toplam kart degeri : " + Odeger +"n 1- Kart Cek : n 2- Pas");
Karar = sc.nextInt();
}
if (oyuncukazandi==false && Odeger<22){
for (int i = 0; i<2; i++)
{
Kart rasgelen = d.kartCek();
System.out.println((i+1)+". Pc Kartlari : "+ rasgelen.sembol + rasgelen.deger);
if (rasgelen.deger>9) rasgelen.deger=10;
PcDeger += rasgelen.deger;
}
System.out.println("Toplam kart degeri : " + PcDeger );
Karar =2;
if (PcDeger<17) Karar =1;
}
if (PcDeger>0){
while (Karar<2)
{
Kart rasgelen = d.kartCek();
System.out.println(("Pc Yeni Karti : "+ rasgelen.sembol + rasgelen.deger));
if (rasgelen.deger>9) rasgelen.deger=10;
PcDeger += rasgelen.deger;
System.out.println("Pc kart degeri : " + PcDeger);
if (PcDeger>17) Karar =2;
if (PcDeger>21) {System.out.println("Pc Kaybetti Oyuncu Kazandi"); oyuncukazandi=true;}
}
}
if (oyuncukazandi==false){
System.out.println("Oyunun Kazanani :");
if (Odeger>PcDeger) {System.out.println("Oyuncu Kazandi");}
else {System.out.println("Pc Kazandi");}
}
}
public Kart kartCek()
{
Kart tmp = null;
for (int i = 0; i<kartlar.length; i++)
{
if (kartlar[i] != null)
{
tmp = kartlar[i];
kartlar[i] = null;
break;
}
}
return tmp;
}
}
![]() |
Notes is a web-based application for online 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 14 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