CATEGORII DOCUMENTE |
Java
Aplicatia cuprinde mai multe clase:
In paginile urmatoare este prezentat codul sursa al acestor clase care alcatuiesc aplicatia. De stiut faptul ca in directorul aplicatiei trebuie sa existe in permanenta 4 directoare, si anume:
In directorul aplicatiei se gaseste fisierul "marfuri.txt" in care sunt trecute marfurile, impreuna cu greutatea si costul lor.
Clasa "CentruDistributie"
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class CentruDistributie extends JFrame implements ActionListener
getContentPane().add(BorderLayout.EAST,new JLabel(' '));
getContentPane().add(BorderLayout.WEST,new JLabel(' '));
getContentPane().add(BorderLayout.NORTH,new JLabel(' Selectati operatiunea dorita'));
getContentPane().add(BorderLayout.CENTER,jp);
getContentPane().add(BorderLayout.SOUTH,new JLabel(' '));
}
public void actionPerformed(ActionEvent ae)
else if (ae.getSource()==jb[0])
Vector v = new Vector();
for (int i=0;i<Marfuri.getDim();i++)
Depozit d = new Depozit(this,v);
d.setResizable(false);
d.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
d.setSize(350,276);
d.setVisible(true);
}
else if (ae.getSource()==jb[2])
}
public static void main(String args[])
}
Clasa "ActDePrimire"
import javax.swing.*;
import java.util.*;
import java.awt.*;
import javax.swing.border.*;
import java.io.*;
public class ActDePrimire extends JDialog
}
bw.close();
}
catch(Exception e)
}
}
Clasa "Depozit"
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.util.*;
public class Depozit extends JDialog
}
}
greutate=Math.round(greutate*1000)/1000.;
tf[0] = new JTextField(''+Furnizori.getDim());
tf[1] = new JTextField(''+marfuri);
tf[2] = new JTextField(''+greutate);
tf[0].setEditable(false);
tf[1].setEditable(false);
tf[2].setEditable(false);
p.setLayout(new GridLayout(3,2));
p.add(new JLabel(' Furnizori'));
p.add(tf[0]);
p.add(new JLabel(' Total marfuri'));
p.add(tf[1]);
p.add(new JLabel(' Total greutate'));
p.add(tf[2]);
p.setBorder(new BevelBorder(BevelBorder.RAISED));
getContentPane().add(BorderLayout.NORTH,p);
getContentPane().add(BorderLayout.CENTER,sp);
}
}
Clasa "ExpediereMarfa"
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.util.*;
import java.io.*;
import java.awt.event.*;
public class ExpediereMarfa extends JDialog implements ActionListener
c[1].addItem('mini furgoneta');
c[1].addItem('furgoneta');
c[1].addItem('camion');
c[1].addItem('tir');
p[0].setLayout(new GridLayout(3,3));
p[0].add(new JLabel(''));
p[0].add(new JLabel(''));
p[0].add(new JLabel(''));
p[0].add(new JLabel(' Selectati zona de distribuire'));
p[0].add(c[0]);
p[0].add(l[3]);
p[0].add(new JLabel(''));
p[0].add(new JLabel(''));
p[0].add(new JLabel(''));
p[0].setBorder(new BevelBorder(BevelBorder.RAISED));
p[1].setLayout(new GridLayout(7,2));
p[1].add(new JLabel(''));
p[1].add(new JLabel(''));
p[1].add(new JLabel(' Tip masina'));
p[1].add(c[1]);
p[1].add(new JLabel(''));
p[1].add(new JLabel(''));
p[1].add(new JLabel(' Greutate minima '));
p[1].add(l[0]);
p[1].add(new JLabel(' Greutate maxima'));
p[1].add(l[1]);
p[1].add(new JLabel(' Cost transport'));
p[1].add(l[2]);
p[1].add(new JLabel(''));
p[1].add(new JLabel(''));
p[2].setLayout(new GridLayout(5,2));
p[2].add(new JLabel(''));
p[2].add(new JLabel(''));
p[2].add(new JLabel(''));
p[2].add(b[0]);
p[2].add(new JLabel(''));
p[2].add(new JLabel(''));
p[2].add(new JLabel(''));
p[2].add(b[1]);
p[2].add(new JLabel(''));
p[2].add(new JLabel(''));
getContentPane().add(BorderLayout.NORTH,p[0]);
getContentPane().add(BorderLayout.WEST,p[1]);
getContentPane().add(BorderLayout.CENTER,p[2]);
c[0].addActionListener(this);
c[1].addActionListener(this);
b[0].addActionListener(this);
b[1].addActionListener(this);
arataDetaliiAutovehicul(0);
arataDetaliiZona(0);
}
public void arataDetaliiZona(int i)
}
}
greutate=Math.round(greutate*1000)/1000.;
l[3].setText(' '+marfuri+' / '+greutate+' kg');
}
public void arataDetaliiAutovehicul(int i)
case 1:
case 2:
case 3:
}
l[2].setText(': '+pret+' lei');
}
public void actionPerformed(ActionEvent ae)
else if(ae.getSource()==c[0])
else if(ae.getSource()==b[0])
else
}
else if(ae.getSource()==b[1])
catch(Exception e)
}
for (int j=0;j<Furnizori.getDim();j++)
}
}
Furnizori.salveazaFurnizori();
Furnizori.stergeFurnizoriiFaraMarfa();
dispose();
}
else
}
}
public boolean ajungeGreutatea()
break;
}
case 2:
break;
}
case 3:
break;
}
}
return true;
}
}
Clasa "FoaieDeParcurs"
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.util.*;
public class FoaieDeParcurs extends JDialog
}
Clasa "Furnizori"
import java.io.*;
public class Furnizori
}
}
catch(Exception e)
System.out.println('Furnizori : '+dim);
}
public static int getDim()
public static int getDim(int i)
public static int getCantitate(int i,int j)
public static String getNume(int i,int j)
public static String getNume(int i)
public static int getMarfa(int i ,int j)
public static int getPrioritate(int i,int j)
public static void stergeMarfa(int i,int j)
public static void salveazaFurnizori()
bw.close();
}
catch(Exception e)
}
}
public static void stergeFurnizoriiFaraMarfa()
catch(Exception e)
}
new Furnizori();
}
class Furnizor
}
catch(Exception e)
salveazaFurnizori();
}
public int getDim()
public String getNume()
public String getCont()
public String getAdresa()
public int getMarfa(int i)
public int getCantitate(int i)
public int getPrioritate(int i)
public String getNume(int i)
public String getNumeFisier()
public void stergeMarfa(int i)
dim--;
}
}
}
Clasa "Marfuri"
import java.io.*;
import java.util.*;
public class Marfuri
}
catch(Exception e)
}
public static int getDim()
public static double getPret(int i)
public static double getGreutate(int i)
public static String getNume(int i)
class Marfa
public String getNume()
public double getPret()
public double getGreutate()
public String toString()
}
}
Clasa "PrimireMarfa"
import javax.swing.*;
import javax.swing.border.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
public class PrimireMarfa extends JDialog implements ActionListener
for (int i=0;i<6;i++)
c[i].addActionListener(this);
}
for (int i=6;i<12;i++)
b[0] = new JButton('Act primire');
b[1] = new JButton('Depoziteaza');
b[0].addActionListener(this);
b[1].addActionListener(this);
p[0].setLayout(new GridLayout(5,3));
p[0].add(b[0]);
p[0].add(new JLabel(''));
p[0].add(b[1]);
p[0].add(new JLabel(''));
p[0].add(new JLabel(' Furnizor'));
p[0].add(new JLabel(''));
p[0].add(new JLabel(' Numele'));
p[0].add(tf[0]);
p[0].add(new JLabel(''));
p[0].add(new JLabel(' Adresa'));
p[0].add(tf[1]);
p[0].add(new JLabel(''));
p[0].add(new JLabel(' Cont bancar'));
p[0].add(tf[2]);
p[0].add(new JLabel(''));
p[0].setBorder(new BevelBorder(BevelBorder.RAISED));
p[1].setLayout(new GridLayout(7,4));
p[1].add(new JLabel(' Marfa'));
p[1].add(new JLabel(' Cantitatea'));
p[1].add(new JLabel(' Destinatar'));
p[1].add(new JLabel(' Prioritate'));
for (int i=0;i<6;i++)
getContentPane().add(BorderLayout.NORTH,p[0]);
getContentPane().add(BorderLayout.CENTER,p[1]);
}
public boolean eCorectCompletata()
if (tmp.indexOf(',')!=-1)
tmp = tf[1].getText();
if (tmp.length()==0)
if (tmp.indexOf(',')!=-1)
tmp = tf[2].getText();
if (tmp.length()==0)
if (tmp.indexOf(',')!=-1)
int k=0;
for (int i=0;i<6;i++)
try
catch(NumberFormatException nfe)
if (Zone.seAflaDestinatar(tf[i+9].getText())==false)
k++;
}
}
if (k==0)
}
catch(Exception e)
return true;
}
public void stergeTot()
for (int i=0;i<12;i++)
}
public void actionPerformed(ActionEvent ae)
ActDePrimire adp = new ActDePrimire(this,tf[0].getText(),tf[1].getText(),tf[2].getText(),x);
adp.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
adp.setSize(550,340);
adp.setResizable(false);
adp.setVisible(true);
}
else
}
else if(ae.getSource()==b[1])
}
bw.close();
}
catch(Exception e)
new Furnizori();
stergeTot();
}
else
}
else if(ae.getSource()==c[0])
else
}
else if(ae.getSource()==c[1])
else
}
else if(ae.getSource()==c[2])
else
}
else if(ae.getSource()==c[3])
else
}
else if(ae.getSource()==c[4])
else
}
else if(ae.getSource()==c[5])
else
}
}
}
import java.io.*;
public class Zone
}
}
catch(Exception e)
System.out.println('Zone de distributie : '+dim);
}
public static int getDim()
public static int getDim(int i)
public static String getNume(int i)
public static String getNume(int i, int j)
public static boolean seAflaDestinatar(int i,String s)
public static boolean seAflaDestinatar(String s)
return false;
}
class Zona
}
catch(Exception e)
}
public String getNume()
public String getNume(int i)
public int getDim()
public boolean seAflaDestinatar(String s)
return false;
}
}
}
Politica de confidentialitate | Termeni si conditii de utilizare |
Vizualizari: 1893
Importanta:
Termeni si conditii de utilizare | Contact
© SCRIGROUP 2024 . All rights reserved