اذا ممكن تساعدوني في ترتيب افكاري & الاكواد انا بدات في عمل
مازلت مشوشة
الفكرة عبارة عن
محل حيوانات
يقدر user
يعمل
add , display ,clear and exit
بالعناصر اللي عندة الموجودة في array
pet name , animal type, breed and colour
a]
1- use only one frame for this program
2- use only one array to store the pet information
b]
1- the program can display individual pets info
2- the program can store all pets info
3- the program can capture the imge of pet and display
4- any other features (edite- delete)
import java.awt.*;
import java.awt.event.*;
public class pet1 extends Frame implements ActionListener
{
pet1 obj[];
static int count = 0;
Button button1, button2, button3, button4;
public pet1()
{
super("PETS");
obj = new pet1[50];
}
public void addComponents()
{
//addComponent("South", new Button("South"));
button1 = new Button("ADD");
button2 = new Button("DISPLAY");
button3 = new Button("CLEAR");
button4 = new Button("EXIT");
add(button1, "South");
add(button2, BorderLayout.SOUTH);
add(button3, BorderLayout.SOUTH);
add(button4, BorderLayout.SOUTH);
pack();
setVisible(true);
button1.addActionListener(this);
//button2.addActionListener(this);
//button3.addActionListener(this);
//button4.addActionListener(this);
}
public void add()
{
TextField tx1 = new TextField(20);
TextField tx2 = new TextField(20);
TextField tx3 = new TextField(20);
TextField tx4 = new TextField(20);
Label colour = new Label("Colour");
Button done = new Button(" Done ");
Button clear = new Button(" Clear ");
supe("ADD");
setLayout(new GridLayout(5,2));
add(new Label(" Name "));
add(tx1);
add(new Label(" Type "));
add(tx2);
add(new Label(" Bead "));
add(tx3);
add(colour);
add(tx4);
add(done);
add(clear);
done.addActionListener(this);
clear.addActionListener(this);
obj[count].name = tx1.getText();
obj[count].type = tx2.getText();
obj[count].bead = tx3.getText();
obj[count].colour = tx4.getText();
count++;
pack();
show();
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == button4)
{
setVisible(false);
dispose();
System.exit(0);
}
else
if (e.getSource() == button1)
add();
}
public static void main(String[] arg)
{
pet1 p = new pet1();
p.addComponents();
//pet1 p1 = new pet1("ADD");
//p1.add();
}
}

