السلام عليكم و رحمة الله و بركاته
هذي اول مشاركة و طلب الي و اتمنى ما تخيبوني ..
بما اني مبتدأة في الجافا صادتني مشكلة في graphic interface اللي يمكن البعض يعتبرها سهله ..ابغي مساعدة في تصميم الديزاين اولا
اتمنى انكم تساعدوني في اسرع وقت لاني متعطلة اسوي implement بسبب design
التصميم عبارة :
grid consists of 100 squares each of 50× 50 with the following shapes:

Radio Button انسوهم لان تم الغاءهم من اللعبة
هذا الكود اللي سويته اللي بس يظهر المربعات بدون الاشكال داخلها و button
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class BestGift extends JFrame implements ActionListener
{
private JButton b1;
private Board area;
public BestGift()
{
JPanel area = new JPanel();
area= new Board();
b1= new JButton("New Game");
Container content = this.getContentPane();
content.add(area,BorderLayout.CENTER);
content.add(b1,BorderLayout.SOUTH);
b1.addActionListener( this);
}
public void actionPerformed(ActionEvent event)
{
/////////////////////
}
public static void main(String[] args)
{
BestGift b = new BestGift();
b.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
b.setSize(509,560);
b.setTitle("Best Gift");
b.setResizable(false);
b.setVisible(true);
}
}// DrawingArea
class Board extends JPanel
{
private Square[][] boardArray;
public Board ()
{
boardArray = new Square[10][10];
for (int row = 0; row < 10; row++)
{
for (int col = 0; col < 10; col++)
{
int x= row*50;
int y= col*50;
boardArray[row][col] = new Square(x,y);
}
}
}
public void paintComponent( Graphics g )
{
super.paintComponent(g);
setBackground(Color.white);
for (int row = 0; row < 10; row++)
{
for (int col = 0; col < 10; col++)
{
int x= row*50;
int y= col*50;
g.drawRect(x,y,50,50);
}
}
}
}// on of square
class Square
{
int x;
int y;
char graphic_type;
boolean locked = false;
public Square(int width,int heigth)
{
x = width;
y = heigth;
// gt = graphic_type;
locked = false;
}
public int getX()
{
return x;
}
public int getY()
{
return y;
}
public void setLocked(boolean locked)
{
this.locked = locked;
}
public void isLocked()
{
locked = true;
}
public boolean locked()
{
return locked;
}
public void setGtype( char gt )
{
graphic_type = gt;
}
public char getGtype( char gt )
{
return graphic_type;
}
}في تصميم grid سويت المربعات فقط، بس اني ابغي اسوي في كل مربع شكل و هذا الشي
موجود في class Square .. parameter من نوع char اللي تدل على نوع الشكل اللي في المربع .. عاد اني ما حطيت هالباراميتر لحد الآن في ..constructer لاني في البداية كنت بصمم المربعات و اشوف الكود شغال لو لا .. و يوم جيت اسوي shape داخله بدت المشكلة.
الفكرة هي في class Board في paint نخلي if statement .. انه مثلا اذا حرف R بتطبق هالكود g.fillRect و اذا حرف A بتطبق كود g.fiiArc و هلما جرى
اني حاولت اسوي هالشي و فشلت فيه لان ما قام يطبق الي اللي سويته.. و بعد انه مستحيل
اخلي array فيها 100 char من shape و بعدين امشي عليها واحط if statment
و فشلت اني اسوي array فيها 3 char للاشكال الثلاثة و اسوي random
لان اللعبة لزما فيها شكلين نفس الشي متتاليين و هالشي اللي ما قدرت اطبقه باستخدام random
ما ادري اذا فهمتون اللي و الا لا
من جد اتمنى تساعدوني في تصميم graphic interface بداية و بعدين اذا صار بحاول استشيركم في implements اذا بديت فيه
