עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

בעית תיכנות ביצירת משחק BLACK JACK למביני עניין ב JAVA - דחוף!!!

Featured Replies

פורסם

קובץ ראשון  cards.java קלפים

public class cards

{

public String sign;

public int value;

cards(String sign_,int value_)

{

this.sign= sign_;

this.value=value_;

}

cards()

{

this("AS",1);

}

}

קובץ שני pack.java חפיסת קלפים

import java.util.*;

import javax.swing.JOptionPane;

public class pack

{

int i,j;

    String st;

private Vector items;

public pack()

{

Vector items = new Vector(52);

for (j=0;j<52;j++)

{

i=(j%14)+1;

switch (i)

{

case 1:st="AS";

break;

case 11: st="PRINCE";

break;

case 12: st="QUEEN";

break;

case 13: st="KING";

break;

default: st=String.valueOf(i);

break;

}

if (i==1) i=10;

cards card = new cards(st,i);

items.add(j,card);

}

}

public cards Get(int n)

{

Object obj = new Object();

cards card1= new cards();

obj=items.elementAt(n);

card1=(cards)obj;

items.remove(n);

return card1;

}

public void mix()

{

int i,x;

Object obj1 = new Object();

Object obj2 = new Object();

cards card1= new cards();

cards card2 = new cards();

Random rang = new Random();

for (i = 1;i<=52;i++)

{

x=rang.nextInt(51)+1;

obj1=items.elementAt(i);

obj2=items.elementAt(x);

card1=(cards)obj1;

card2=(cards)obj2;

items.set(i,card2);

items.set(x,card1);

}

}

public void tostring()

{

int n;

String st;

n=items.size();

if (n==0)

{

JOptionPane.showMessageDialog(null,"NO MORE CARDS IN THE PACKAGE!!!","",JOptionPane.INFORMATION_MESSAGE);

}

else

{

st=String.valueOf(n);

JOptionPane.showMessageDialog(null,"THE NUMBER OF CARDS IN THIS PACKAGE IS: "+st,"",JOptionPane.INFORMATION_MESSAGE);

}

}

}

קובץ שלישי blakjack.java

public class blakjack

{

public static void main(String[] args)

{

String st;

Object obj = new Object();

cards card = new cards();

pack s = new pack();

s.Get(1);

//card=(cards)obj;

//st=String.valueOf(card.value);

//JOptionPane.showMessageDialog(null,"THE NUMBER OF CARDS IN THIS PACKAGE IS: "+st,"",JOptionPane.INFORMATION_MESSAGE);

}

}

אני צריך ליצור שני קבצי class אחד של קלף והשני של חפיסת קלפים

בסופו של דבר אני צריך ליצור את המשחק 21 או בלק ג'ק בלשון העם

משום מה אני מגיע ל fatel EROER

ואין לי מושג למה

ב CLASS של ה MAIN

עשיתי ניסיון ומשום מה זה מעיף אותי

אשמח לקבל תשובה בהקדם האפשרי

פורסם

קרא את חוקי הפורום ושנה את הכותרת בהתאם.

פורסם

תתחיל בזה שתסביר לעצמך את משמעות השורה

Vector items = new Vector(52);

למקרה ולא הבנת, הגדרת משתנה חדש (שקיים רק בפונקציה שלך -- pack ), שבמקרה יש לו אותו שם כמו ל data mmember שלך,

פתרון תחליף את השורה ב

items = new Vector(52);

מטי.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.