Documente Academic
Documente Profesional
Documente Cultură
Chiinu 2014
Cod sursa:
import java.applet.*;
1
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class My_applette extends Applet implements ActionListener
{ String den_petrecere, slider, tip_party_string, where, tip_torta,rez;
Image img_title_left, img_error, z_1, z_2, p_1, p_2, f_1, n_1, m_1;
JSlider quantity;
Choice where_party, tip_party,torta;
Image bg_1, bg_2, bg_3, bg_4;
Button go;
public void init()
{
setSize(1000, 700);
setBackground(Color.black);
den_petrecere=" Party of Moldova";
slider = "Pipols of party";
tip_party_string = "Tip of party";
where = "Where is The Party";
tip_torta = "Cake for Party";
rez="Pagube>>>>>";
img_title_left = getImage(getDocumentBase(),"1.jpg");
img_error = getImage(getDocumentBase(), "2.jpg");
z_1 = getImage(getDocumentBase(), "z_1.jpg");
z_2 = getImage(getDocumentBase(), "z_2.jpg");
p_1 = getImage(getDocumentBase(), "p_1.jpg");
p_2 = getImage(getDocumentBase(), "p_2.jpg");
f_1 = getImage(getDocumentBase(), "f_1.jpg");
2
torta.insert("Diplomat", 2);
torta.insert("Medovii", 3);// Party
torta.insert("Capucino", 4);//
add(torta);
go = new Button("Start of Party");
go.addActionListener(this);
add(go);
}
public void paint(Graphics g)
{
//fonturi
Font f = new Font("Algerian", Font.BOLD, 50);
Font ff = new Font("Algerian", Font.BOLD, 36);
Font fff = new Font("Algerian", Font.BOLD + Font.ITALIC, 20);
//titlul
g.setColor(Color.red);
g.setFont(f);
g.drawString(den_petrecere, 420, 50);
//showStatus(" Displaying Text at Center of Screen");
//tip of party
g.setColor(Color.green);
4
g.setFont(ff);
g.drawString(tip_party_string, 10, 250);
tip_party.setBounds(15, 265, 100, 20);
//where
g.setColor(Color.blue);
g.setFont(ff);
g.drawString(where, 10, 320);
where_party.setLocation(15, 332);
//tip torta
g.setColor(Color.red);
g.setFont(ff);
g.drawString(tip_torta, 10, 420);
torta.setBounds(15, 430, 100, 20);
//sliderul
g.setColor(Color.orange);
g.setFont(ff);
g.drawString(slider, 10, 500);
quantity.setBounds(10, 520, 400, 50);
g.setColor(Color.black);
g.drawRect(8, 480, 403, 55);
//rezulatul party
g.setFont(fff);
g.setColor(Color.red);
g.drawString(rez, 450, 500)
//butonul
go.setLocation(300, 600);
5
// wedding
if(tip_party.getSelectedItem().equals("Wedding Party") &&
where_party.getSelectedItem().equals("Adam&Eva")
&& (torta.getSelectedItem().equals("Gingasie ") ||
torta.getSelectedItem().equals("Diplomat")) && quantity.getValue() < 20)
{
g.drawImage(z_1, 500, 150, this);
// Christening Party
if(tip_party.getSelectedItem().equals("Christening Party") &&
where_party.getSelectedItem().equals("Adam&Eva")
&& torta.getSelectedItem().equals("Capucino") && quantity.getValue() < 6)
{
g.drawImage(p_1, 500, 150, this);
}
//Birthday Party
if(tip_party.getSelectedItem().equals("Birthday Party") &&
where_party.getSelectedItem().equals("Andy's Pizza")
&& (torta.getSelectedItem().equals("Gingasie") ||
torta.getSelectedItem().equals("Capucino")) && quantity.getValue() < 80)
{
g.drawImage(f_1, 500, 150, this);
}
//Girl Party
if(tip_party.getSelectedItem().equals("Girl Party") &&
where_party.getSelectedItem().equals("Disco")
&& (torta.getSelectedItem().equals("Gingasie") ||
torta.getSelectedItem().equals("Medovii")) && quantity.getValue() <= 100)
{
g.drawImage(n_1, 500, 150, this);
}
//Boys Party
if(tip_party.getSelectedItem().equals("Boys Party") &&
where_party.getSelectedItem().equals("Disco")
&& torta.getSelectedItem().equals("Diplomat") && quantity.getValue() <= 100)
{
7
// }
repaint();
}