O programa esta em C# porque não sei fazer interface em java e também porque apesar dele ter sintaxe muito diferente, ele é muito parecido “estruturalmente” com java.
Se alguém puder me ajudar com qualquer coisa, tutorial, exemplo qualquer material, ficerei agradecido.
Interface:
namespace WindowsFormsApplication1
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(29, 55);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(157, 61);
this.button1.TabIndex = 0;
this.button1.Text = "Entrou um veiculo";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(626, 55);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(142, 61);
this.button2.TabIndex = 1;
this.button2.Text = "sail um veiculo";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// textBox1
//
this.textBox1.AcceptsReturn = true;
this.textBox1.AcceptsTab = true;
this.textBox1.AccessibleName = "TextBox1";
this.textBox1.Location = new System.Drawing.Point(473, 56);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 22);
this.textBox1.TabIndex = 2;
this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
//
// textBox2
//
this.textBox2.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox2.Location = new System.Drawing.Point(473, 114);
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(100, 22);
this.textBox2.TabIndex = 3;
//
// textBox3
//
this.textBox3.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.textBox3.Location = new System.Drawing.Point(473, 186);
this.textBox3.Name = "textBox3";
this.textBox3.ReadOnly = true;
this.textBox3.Size = new System.Drawing.Size(100, 22);
this.textBox3.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(238, 59);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(198, 17);
this.label1.TabIndex = 5;
this.label1.Text = "Entre com o numero de vagas";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(238, 119);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(122, 17);
this.label2.TabIndex = 6;
this.label2.Text = "Vagas disponiveis";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(238, 189);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(114, 17);
this.label3.TabIndex = 7;
this.label3.Text = "Vagas ocupadas";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(815, 320);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox3);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Contador de vagas de um estacionamento.";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
public System.Windows.Forms.TextBox textBox1;
public System.Windows.Forms.TextBox textBox2;
public System.Windows.Forms.TextBox textBox3;
}
}
A parte de controle abaixo:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public
partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Variaveis globais
int vagdis, vagoc, vagtot;
public void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
vagtot = System.Convert.ToInt16(textBox1.Text);
vagoc = 0;
vagdis = vagtot;
textBox3.Text = vagoc.ToString();
textBox2.Text = vagdis.ToString();
}
catch
{
MessageBox.Show("erroo!!!!, errroo");
}
}
public void Form1_Load(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
vagoc = vagoc + 1;
vagdis = vagdis - 1;
textBox3.Text = vagoc.ToString();
textBox2.Text = vagdis.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
vagoc = vagoc - 1;
vagdis = vagdis + 1;
textBox3.Text = vagoc.ToString();
textBox2.Text = vagdis.ToString();
}
}
}
EDIT: Explicando como funcionar:
cara… interface em Java… não implementa nenhum método… apenas possui a assinatura dos métodos… já as classes que implementam essa interface se encarregam disso…
você podia ajudar… e descrever como é o funcionamento de uma interface em C#… ou explicar o que essa classe aí faz…?
Não é necessário método em java.
É mais ou menos assim: 3 caixas de texto e 2 botões.
Uma caixa de texto armasena o número de vagas disponivel, uma o número ocupado e um o total.
É lido o número total de vagas e a quantidade disponível inicia-se com o total. O número ocupado inicia-se como 0.
Ao entrar um carro, um sensor representado com botão é precionado e com isto, o número de vagas disponíveis é decrementado em 1 unidade, ocupadas, acrescentado em 1 unidade e o total permanece constante. Depois disto, estes valores são passados a caixas de texto.
Se sair, o sensor representado por outro botão é acionado, o número de vagas ocupadas é decrementado em 1 unidade, e disponiveis, acrescentado em 1 unidade e o total permanece constante. Depois disto, estes valores são passados a caixas de texto.
Fazendo isto sabe-se o número de vagas disponíveis, ocupadas e total no estacionamento.
RESOLVIDO!!!