You are on page 1of 4

Ministerul Educaiei al Republicii Moldova

Universitatea Tehnic a Moldovei


Catedra: Calculatoare

RAPORT

Lucrare de laborator Nr.3


La Programarea Orientata pe Obiecte

A efectuat: st. gr. C-141


Grigoras
Constantin
A verificat: lect.sup. Rotaru
Lilia

Chiinu 2016
Lucrare de laborator Nr_3 la POO
________________________________________________________________________
var.3

Tema: Motenirea
Conditia problemei:
Pentru toate variantele extindei capacitile clasei de baz dat folosind motenirea:

3.Time, astfel nct s se poat deduce timpul trecut de la o aciune specificata.

Listingul programei :
package mandarin;

import java.awt.EventQueue;
import java.sql.Time;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Font;
import javax.swing.SwingConstants;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class lab33{

private JFrame frame;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
lab33 window = new lab33();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the application.
*/
public lab33() {
initialize();
}

class MyTime extends Time{


public MyTime() {
super(System.currentTimeMillis());
}
public MyTime(int hour, int minute, int second) {
super(hour,minute,second);
}
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {

frame = new JFrame();


frame.setBounds(100, 100, 200, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);

JPanel panel = new JPanel();


panel.setBounds(0, 0, 184, 161);
frame.getContentPane().add(panel);
panel.setLayout(null);

JLabel lblIterato = new JLabel("");


lblIterato.setBounds(66, 11, 89, 14);
panel.add(lblIterato);

JLabel label = new JLabel("");


label.setBounds(66, 31, 89, 14);
panel.add(label);

JLabel label_1 = new JLabel("0");


label_1.setBounds(109, 73, 46, 14);
panel.add(label_1);

JLabel lblTime = new JLabel("Elapsed");


lblTime.setHorizontalAlignment(SwingConstants.CENTER);
lblTime.setBounds(10, 69, 54, 23);
panel.add(lblTime);

JButton btnNewButton = new JButton("SetTime");


btnNewButton.setFont(new Font("Tahoma", Font.PLAIN, 11));
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
lblIterato.setText(new MyTime().toString());

}
});
btnNewButton.setBounds(10, 103, 83, 23);
panel.add(btnNewButton);

JButton btnGettime = new JButton("GetTime");


btnGettime.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
label.setText(new MyTime().toString());

String text1 =lblIterato.getText();


String text2 =label.getText();
int i = 0;
int u = 0;
i=Integer.parseInt(text1.replaceAll("[\\D]", ""));
u=Integer.parseInt(text2.replaceAll("[\\D]", ""));
int m=u-i;

label_1.setText(Integer.toString(m));
}
});
btnGettime.setFont(new Font("Tahoma", Font.PLAIN, 11));
btnGettime.setBounds(91, 103, 83, 23);
panel.add(btnGettime);

}
}
Rezultatul programului:

You might also like