java叫号系统代码 叫号排队系统java-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

java叫号系统代码 叫号排队系统java

用java语言编写一个小型的银行系统代码

private int balance = 0;

在卫辉等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供做网站、网站设计 网站设计制作按需策划设计,公司网站建设,企业网站建设,高端网站设计,成都全网营销推广,外贸营销网站建设,卫辉网站建设费用合理。

private  String username = "A";

private  String password = "B";

public void bank() {

Scanner scan = new Scanner(System.in);

String  temp;

while (true) {

System.out.println("输入账号:");

if (scan.hasNext()) {

temp = scan.next();

if (temp.equals(username)) {

break;

} else {

System.out.println("输入错误");

}

}

}

while (true) {

System.out.println("输入密码:");

if (scan.hasNext()) {

temp = scan.next();

if (temp.equals(password)) {

break;

} else {

System.out.println("输入错误");

}

}

}

System.out.println("登录成功");

while (true) {

System.out.println("输入操作:");

if (scan.hasNext()) {

temp = scan.next();

switch (temp) {

case "存款":

int x = 0;

while (true) {

System.out.println("输入存款金额:");

if (scan.hasNextInt()) {

x = scan.nextInt();

break;

} else {

System.out.println("输入错误");

scan.next();

}

}

balance += x;

break;

case "取款":

int y = 0;

while (true) {

System.out.println("输入取款金额:");

if (scan.hasNextInt()) {

y = scan.nextInt();

if (balance  y) {

System.out.println("余额不足");

continue;

}

break;

} else {

System.out.println("输入错误");

scan.next();

}

}

balance -= y;

break;

case "余额":

System.out.println("余额:" + balance);

break;

case "终止":

System.exit(0);

default:

System.out.println("未知操作");

}

}

}

用java实现银行排队程序,要求模拟银行的业务排队系统,要有界面,实现完成的排队和叫号

import java.awt.Color;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.WindowAdapter;

import java.awt.event.WindowEvent;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JTextField;

public class BankWaiting extends JFrame implements ActionListener {

int total = 0, now = 0;

boolean is1Ready = false, is2Ready = false, is3Ready = false;

int call1, call2, call3;

JFrame jf;

JLabel jr, jl, jl1, j2, jl2, j3, jl3;

JTextField jr4;

JButton jb, jb1, jb2, j1;

JButton workBut1, workBut2, workBut3;

JPanel jp, jp1, jp2;

public BankWaiting() {

setLayout(null);

jf = new JFrame("银行叫号程序");// 窗体

jr = new JLabel("请**号到*号窗口办理业务");

jr.setBounds(300, 10, 800, 50);

jr.setForeground(Color.red);

j1 = new JButton("取号");

j1.addActionListener(this);

jr4 = new JTextField("欢迎");

jr4.setEditable(false);

ButtonGroup bg = new ButtonGroup();

bg.add(j1);

jp = new JPanel();

jl = new JLabel("一号窗口");

jl1 = new JLabel("一号窗口,欢迎你!");

jb = new JButton("下一位");

workBut1 = new JButton("开始办理");

workBut1.addActionListener(this);

jb.addActionListener(this);

jp.setBackground(Color.pink);

jp.setSize(200, 80);// 大小

jp.setLocation(20, 120); // 位置

jf.setLayout(null);

jp1 = new JPanel();

j2 = new JLabel("二号窗口");

jl2 = new JLabel("二号窗口,欢迎你!");

jb1 = new JButton("下一位");

workBut2 = new JButton("开始办理");

jb1.addActionListener(this);

workBut2.addActionListener(this);

jp1.setBackground(Color.pink);

jp1.setSize(200, 80);// 大小

jp1.setLocation(250, 120); // 位置

jf.setLayout(null);

jp2 = new JPanel();

j3 = new JLabel("三号窗口");

jl3 = new JLabel("三号窗口,欢迎你!");

jb2 = new JButton("下一位");

workBut3 = new JButton("开始办理");

workBut3.addActionListener(this);

jb2.addActionListener(this);

jp2.setBackground(Color.pink);

jp2.setSize(200, 80);// 大小

jp2.setLocation(500, 120); // 位置

jf.setLayout(null);

jf.add(jp);

jf.add(jp1);

jf.add(jp2);

jf.add(jr);

jp.add(jl);

jp.add(jl1);

jp.add(jb);

jp.add(workBut1);

jp1.add(j2);

jp1.add(jl2);

jp1.add(jb1);

jp1.add(workBut2);

jp2.add(j3);

jp2.add(jl3);

jp2.add(jb2);

jp2.add(workBut3);

jf.add(j1);

jf.add(jr4);

j1.setBounds(550, 300, 60, 30);

jr4.setBounds(300, 300, 200, 40);

jf.setSize(800, 600);

jf.setVisible(true);

jf.addWindowListener(new WindowAdapter() {

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

}

public void actionPerformed(ActionEvent e) {

String s = "";

if (e.getSource() == j1) {

s = "第" + (++total) + "号,前面还有" + (total - now - 1) + "位顾客!";

jr4.setText(s);

}

if (e.getSource() == jb) {

if (this.hasCustomers()) {

s = "请" + (++now) + "号顾客到一号窗口办理";

call1 = now;

jl1.setText(s);

jr.setText(s);

is1Ready = true;

} else {

s = "当前已经没有顾客了";

jl1.setText(s);

is1Ready = false;

}

} else if (e.getSource() == jb1) {

if (this.hasCustomers()) {

s = "请" + (++now) + "号顾客到二号窗口办理";

call2 = now;

jl2.setText(s);

jr.setText(s);

is2Ready = true;

} else {

s = "当前已经没有顾客了";

jl2.setText(s);

is2Ready = false;

}

} else if (e.getSource() == jb2) {

if (this.hasCustomers()) {

s = "请" + (++now) + "号顾客到三号窗口办理";

call3 = now;

jl3.setText(s);

jr.setText(s);

is3Ready = true;

} else {

s = "当前已经没有顾客了";

jl3.setText(s);

is3Ready = false;

}

}

if (e.getSource() == workBut1) {

if (is1Ready) {

s = call1 + "号顾客正在办理业务。。。";

jl1.setText(s);

is1Ready = false;

}

} else if (e.getSource() == workBut2) {

if (is2Ready) {

s = call2 + "号顾客正在办理业务。。。";

jl2.setText(s);

is2Ready = false;

}

} else if (e.getSource() == workBut3) {

if (is3Ready) {

s = call3 + "号顾客正在办理业务。。。";

jl3.setText(s);

is3Ready = false;

}

}

}

public boolean hasCustomers() {

if (now total) {

return true;

} else {

return false;

}

}

public static void main(String[] args) {

new BankWaiting();

}

}

java通讯录管理系统设计代码怎么编译

java编写这个通讯录管理系统

java编写这个通讯录管理系统_Java如何实现通讯录管理系统

咕噜噜在芬兰

原创

关注

3点赞·2305人阅读

Java如何实现通讯录管理系统

发布时间:2020-07-28 09:39:42

来源:亿速云

阅读:65

作者:Leah

这篇文章将为大家详细讲解有关Java如何实现通讯录管理系统,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

本文实例为大家分享了java实现通讯录管理系统的具体代码,供大家参考,具体内容如下

完成项目的流程:

1.根据需求,确定大体方向

2.功能模块分析

3.界面实现

4.功能模块设计

5.coding

6.代码测试

下面是源代码:import java.awt.Container;

import java.awt.GridLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.io.BufferedReader;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.util.ArrayList;

import java.util.Scanner;

import java.util.concurrent.SynchronousQueue;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.WindowConstants;

import javax.swing.text.html.HTMLDocument.Iterator;

class Infro{

public String id;

public String name;

public String sex;

public String address;

public String e_mail;

public String phoneNumber;

static int index = 0;

static ArrayList list = new ArrayList();

static int len = list.size();

//构造函数

public Infro(String id,String name,String sex,String address,String e_mail,String phoneNumber){

this.id = id;

this.name = name;

this.sex = sex;

this.address = address;

this.e_mail = e_mail;

this.phoneNumber = phoneNumber;

}

public String toString(){

return "编号:"+id+" 姓名:"+name+" 性别:"+sex+" 通讯地址:"+address+" 邮箱地址:"+e_mail+" 电话:"+phoneNumber;

}

/**

* 添加功能

**/

public static void addFunction(){//添加功能

Infro infro = new Infro("","","","","","");

System.out.println("请输入添加的数据:");

Scanner in = new Scanner(System.in);

System.out.println("输入编号:");

infro.id = in.next();

System.out.println("输入姓名:");

infro.name = in.next();

System.out.println("输入性别:");

infro.sex = in.next();

System.out.println("输入通讯地址:");

infro.address = in.next();

System.

out.println("输入邮箱地址:");

infro.e_mail = in.next();

System.out.println("输入电话:");

infro.phoneNumber = in.next();

list.add(index,infro);

index++;

if(list.isEmpty()){

System.out.println("数据添加失败啦");

}else{

System.out.println("数据添加成功啦");

len++;//list集合长度加一

// System.out.println(list.get(0).toString());

}

}

// public static void deleteFunction(){//删除功能

// System.out.println("输入要删除的联系人的编号");

// Scanner in_2 = new Scanner(System.in);

// String d1 = in_2.nextLine();

// for(int a= 0; a

// if(d1.equals(list.get(a).id)){

// list.remove(list.get(a));

// len --;

// }

// }

// }

/**

* 删除功能

**/

public static void deleteFunction(){

System.out.println("输入要删除的联系人的编号");

Scanner in_2 = new Scanner(System.in);

String d1 = in_2.nextLine();

java.util.Iterator it = list.iterator();

while (it.hasNext()){

Infro infro = it.next();

if (infro.id.equals(d1)){

it.remove();

--index;//一定要加这个,否则当做了删除操作再做添加操作的时候会出现异常(类似于指针,栈)

System.out.println("删除完毕"+"此时通讯录记录条数为:" + --len);

}

}

}

/**

* 修改功能

**/

public static void reditFunction(){

System.out.println("输入要修改的通讯录的Id");

Scanner in_r = new Scanner(System.in);

String r1 = in_r.nextLine();

for(int a = 0; a len;a++){

if(r1.equals(list.get(a).id)){

System.out.println("输入修改后的姓名:");

String name_1 = in_r.next();

list.get(a).name = name_1;

System.out.println("输入修改后的性别:");

String sex_1 = in_r.next();

list.get(a).sex = sex_1;

System.out.println("输入修改后的通讯地址:");

String address_1 = in_r.next();

list.get(a).address = address_1;

System.out.println("输入修改后的邮箱地址:");

String e_mail_1 = in_r.next();

list.get(a).e_mail = e_mail_1;

System.out.println("输入修改后的电话:");

String phoneNumber_1 = in_r.next();

list.get(a).phoneNumber = phoneNumber_1;

System.out.println("数据修改完毕");

}

}

}

/**

* 查询功能

**/

public static void searchFunction() throws Exception{//查询功能

System.out.println("请输入要查询的姓名:");

Scanner in_1 = new Scanner(System.in);

String s1=in_1.nextLine();

for(int a= 0; a

if(s1.equals(list.get(a).name)){

System.out.println(list.get(a).toString());

}

}

}

/**

* 显示功能

**/

public static void showFunction(){

for(int i = 0 ;i

System.out.println(list.get(i).toString());

}

}

/**

* 保存功能

**/

public static void writeFunction() throws IOException{

FileWriter writer = new FileWriter("通讯录管理.txt");

for(int i = 0 ;i

String []strwriter = new String[len];

strwriter[i]=list.get(i).toString();

writer.write(strwriter[i]);

writer.write("\r\n");

System.out.println("成功写入一行数据到 通讯录管理.txt 中");

}

writer.close();//关闭写入流,释放资源

}

/**

* 读取功能

**/

public static void readFunction() throws IOException{

FileReader reader = new FileReader("通讯录管理.txt");

BufferedReader br = new BufferedReader(reader);

String str;

while((str = br.readLine()) != null){//每次读取一行文本,判断是否到达文件尾

System.out.println(str);

}

br.close();

}

}

public class Demo extends JFrame {

/**

* 界面设计

**/

public Demo(){

Container c = getContentPane(); //定义一个顶级容器c

JPanel jp = new JPanel(); //新建JPanel面板--jp

JButton button1 = new JButton("新建联系人");

JButton button2 = new JButton("删除联系人");

JButton button3 = new JButton("编辑联系人");

JButton button4 = new JButton("查找联系人");

JButton button5 = new JButton("显示所有联系人");

JButton button6 = new JButton("保存联系人到本地");

JButton button7 = new JButton("读取本地联系人");

jp.setLayout(new GridLayout(2,4,5,5));//新建网格布局管理器(行数,列数,组件间的水平垂直间距)

jp.add(button1);

jp.add(button2);

jp.add(button3);

jp.add(button4);

jp.add(button5);

jp.add(button6);

jp.add(button7);

c.add(jp);//将JPanel面板jp添加到顶级容器c中

setSize(600,500);

setTitle("*通 讯 录 管 理 系 统*");

setVisible(true);

setResizable(false);//窗体大小由程序员决定,用户不能自由改变大小

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

/**

*按键响应

*

**/

button1.addActionListener(new ActionListener(){//添加功能实现

public void actionPerformed(ActionEvent arg0){

Infro.addFunction();

}

});

button2.addActionListener(new ActionListener(){//删除功能实现

public void actionPerformed(ActionEvent arg0){

Infro.deleteFunction();

}

});

button3.addActionListener(new ActionListener(){//修改功能实现

public void actionPerformed(ActionEvent arg0){

Infro.reditFunction();

}

});

button4.addActionListener(new ActionListener(){//查询功能实现

public void actionPerformed(ActionEvent arg0){

try {

Infro.searchFunction();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

button5.addActionListener(new ActionListener(){//显示功能实现

public void actionPerformed(ActionEvent arg0){

Infro.showFunction();

}

});

button6.addActionListener(new ActionListener(){//保存功能实现

public void actionPerformed(ActionEvent arg0){

try {

Infro.writeFunction();

} catch (IOException e) {

e.printStackTrace();

}

}

});

button7.addActionListener(new ActionListener(){//读取功能实现

public void actionPerformed(ActionEvent arg0){

try {

Infro.readFunction();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

}

public static void main(String[] args) {

// TODO Auto-generated method stub

new Demo();

Infro a = new Infro("", "", "", "", "", "");

}

}

关于Java如何实现通讯录管理系统就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

求java中类似学生信息管理系统中按学号,按姓名排序的代码

import java.util.ArrayList;

import java.util.Collections;

import java.util.Comparator;

import java.util.List;

public class Sort {

public static void main(String[] args) {

Student p1 = new Student(1001, "小明", 20);

Student p2 = new Student(1002, "小红", 21);

Student p3 = new Student(1003, "小黑", 19);

ListStudent list = new ArrayListStudent();

list.add(p1);

list.add(p2);

list.add(p3);

Collections.sort(list, new ComparatorStudent() {

/*

 * int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,

 * 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。

 */

public int compare(Student o1, Student o2) {

// 按照学生的学号进行升序排列

if (o1.getId()  o2.getId()) {

return 1;

}

if (o1.getId() == o2.getId()) {

return 0;

}

return -1;

}

});

write(list);

System.out.println("---------------------");

Collections.sort(list, new ComparatorStudent() {

/*

 * int compare(Student o1, Student o2) 返回一个基本类型的整型, 返回负数表示:o1 小于o2,

 * 返回0 表示:o1和o2相等, 返回正数表示:o1大于o2。

 */

public int compare(Student o1, Student o2) {

// 按照学生的年龄进行升序排列

if (o1.getAge()  o2.getAge()) {

return 1;

}

if (o1.getAge() == o2.getAge()) {

return 0;

}

return -1;

}

});

write(list);

}

public static void write(ListStudent list) {

for (Student s : list) {

System.out.println(s.getId() + "\t" + s.getName() + "\t"

+ s.getAge());

}

}

}

public class Student {

private int id ;

private String name;

private int age;

//构造方法

public Student(int id,String name,int age){

this.id = id;

this.name = name;

this.age = age;

}

public int getId() {

return id;

}

public void setId(int id) {

this.id = id;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public int getAge() {

return age;

}

public void setAge(int age) {

this.age = age;

}

}

用java编的银行账户系统代码

package pack.money.persistent;import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.util.ArrayList;import pack.money.entity.Client;

import pack.money.entity.ClientMessage;

public class ClientPersistent {

//private static int a=0;

private static String t,b;//t是password b是clinetname

private static ClientPersistent sp;

public static ClientPersistent getClientPersistent() {

if (sp == null) {

sp = new ClientPersistent();

}

return sp;

}

private ClientMessage getClientMessage(ResultSet rs) throws Exception{

ClientMessage student=new ClientMessage();

student.setMoney(rs.getFloat("money"));

student.setType(rs.getString("type"));

student.setClientName(rs.getString("ClientName"));

student.setTransactionID(rs.getInt("TransactionID"));

return student;

}

public Client login(Connection con,String ClientName,String password) throws Exception{

String sql="select balance,password,ClientName from Client where ClientName=? and password=?";

PreparedStatement ps=con.prepareStatement(sql);

ps.setString(1, ClientName);

ps.setString(2, password);

ResultSet rs=ps.executeQuery();

t=password;

b=ClientName;

System.out.println(t);

System.out.println(b);

if(rs.next()){

Client client=new Client();

client.setClientName(rs.getString("ClientName"));

client.setPassword(rs.getString("password"));

return client; }

throw new Exception("Can not login, the accountID or password has error. ");

} public void save(Connection con ,String money)throws Exception

{ // a++;

String s="save";

float g=Float.parseFloat(money);

String sql="update Client set balance=balance+? where ClientName=?";

String sql1="insert into ATMTransaction(ClientName,Type,money) values(?,?,?) ";

PreparedStatement ps=con.prepareStatement(sql);

PreparedStatement ps1=con.prepareStatement(sql1);

ps.setFloat(1, g);

ps.setString(2,b);

//ps1.setInt(1,a);

ps1.setString(1,b);

ps1.setString(2,s);

ps1.setFloat(3,g);

ps.executeUpdate();

ps1.executeUpdate();

}

public void withDraw (Connection con ,String money)throws Exception

{ //a++;

String s="WithDraw";

float x=Float.parseFloat(money);

String sql="update Client set balance=balance-? where ClientName=?";

String sql1="insert into ATMTransaction(ClientName,Type,money) values(?,?,?)";

PreparedStatement ps=con.prepareStatement(sql);

PreparedStatement ps1=con.prepareStatement(sql1);

ps.setFloat(1, x);

ps.setString(2,b);

//ps1.setInt(1,a);

ps1.setString(1,b);

ps1.setString(2,s);

ps1.setFloat(3,x);

ps.executeUpdate();

ps1.executeUpdate();

}

public String changePassword(Connection con, String OldPassWord,String newPassWord1,String newPassWord2)

throws Exception

{

if(t.equals(OldPassWord))

{

if(newPassWord1.equals(newPassWord2))

{

String sql="update Client set password=? where ClientName=?";

PreparedStatement ps=con.prepareStatement(sql);

ps.setString(1, newPassWord1);

ps.setString(2,b);

ps.executeUpdate();

String j="dsfasdf";

return j;

}

else

{System.out.print("确认密码错误!");br return null;}

}

else

{ return null;

}

}

public ArrayListClientMessage disPlayAll(Connection con ) throws Exception

{

String sql="select * from ATMTransaction where ClientName=? ";

PreparedStatement ps=con.prepareStatement(sql);

ps.setString(1,b);

System.out.println(b+"****b****");

ResultSet rs=ps.executeQuery();

ArrayListClientMessage message=new ArrayListClientMessage();

while(rs.next()){

message.add(this.getClientMessage(rs));

}

return message;

}

public float showBalance(Connection con ) throws Exception

{

String sql="select balance from Client where ClientName=?";

PreparedStatement ps=con.prepareStatement(sql);

ps.setString(1, b);

ResultSet rs=ps.executeQuery();

if(rs.next())

{

float s;

s=rs.getFloat("balance");

return s;

}

else return 0 ;

}

}


当前标题:java叫号系统代码 叫号排队系统java
文章路径:http://kswsj.cn/article/hphggp.html

其他资讯