系统设计代码java 系统设计代码设计

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编写的商品库存管理系统的设计思路以及源代码是什么?

既然是商品库存系统,那么最少有各种商品的单件信息,1:需要有商品的进货价格,卖出价格,剩余数量,每月的销售数量,进货时间等,在对应的数据库表创建相应的字段。2:商品管理就是对多种商品的管理,所以还要有各种商品的分类,比如烟酒类,饮料类,小吃类,将其分类好管理,同样数据库里面建立相对的数据表。具体需要根据自己需求来编写。3:界面的设计,这里可分为登陆界面,其中一个是用户登陆后查看的界面,和管理员登陆后查看的界面,用户登录只能查看对应的商店的物品管理,并且能进行修改自家商品。管理员登陆可查看所有的用户的商店物品,及修改物品信息。而物品分类栏就可以用jQuery来实现局部的刷新界面。左边为物品分类栏,右边为选中物品类的信息。点击右边分类物品的某件物品,可跳转到该类物品的单个信息,如第1点提到的。

java设计个小系统

100来行就能实现个系统?楼主想简单了。不过你可以参考我的这个:

import javax.swing.JTable;

import javax.swing.table.AbstractTableModel;

import javax.swing.JScrollPane;

import javax.swing.JFrame;

import javax.swing.SwingUtilities;

import javax.swing.JOptionPane;

import java.awt.*;

import java.awt.event.*;

public class TableDemo extends JFrame

{

private boolean DEBUG = true;

public TableDemo()

{ //实现构造方法

super("RecorderOfWorkers"); //首先调用父类JFrame的构造方法生成一个窗口

MyTableModel myModel = new MyTableModel();//myModel存放表格的数据

JTable table = new JTable(myModel);//表格对象table的数据来源是myModel对象

table.setPreferredScrollableViewportSize(new Dimension(500, 70));//表格的显示尺寸

//产生一个带滚动条的面板

JScrollPane scrollPane = new JScrollPane(table);

//将带滚动条的面板添加入窗口中

getContentPane().add(scrollPane, BorderLayout.CENTER);

addWindowListener(new WindowAdapter() {//注册窗口监听器

public void windowClosing(WindowEvent e) {

System.exit(0);

}

});

}

//把要显示在表格中的数据存入字符串数组和Object数组中

class MyTableModel extends AbstractTableModel {

//表格中第一行所要显示的内容存放在字符串数组columnNames中

final String[] columnNames = {"First Name",

"Position",

"Telephone",

"MonthlyPay",

"Married"};

//表格中各行的内容保存在二维数组data中

final Object[][] data = {

{"Wang Yi", "Executive",

"01068790231", new Integer(5000), new Boolean(false)},

{"Li Si", "Secretary",

"01069785321", new Integer(3500), new Boolean(true)},

{"Li Wu", "Manager",

"01065498732", new Integer(4500), new Boolean(false)},

{"Zhao Liu", "Safeguard",

"01062796879", new Integer(2000), new Boolean(true)},

{"Chen Qi", "Salesman",

"01063541298", new Integer(4000), new Boolean(false)}

};

//下述方法是重写AbstractTableModel中的方法,其主要用途是被JTable对象调用,///以便在表格中正确的显示出来。程序员必须根据采用的数据类型加以恰当实现。

//获得列的数目

public int getColumnCount() {

return columnNames.length;

}

//获得行的数目

public int getRowCount() {

return data.length;

}

//获得某列的名字,而目前各列的名字保存在字符串数组columnNames中

public String getColumnName(int col) {

return columnNames[col];

}

//获得某行某列的数据,而数据保存在对象数组data中

public Object getValueAt(int row, int col) {

return data[row][col];

}

//判断每个单元格的类型

public Class getColumnClass(int c) {

return getValueAt(0, c).getClass();

}

//将表格声明为可编辑的

public boolean isCellEditable(int row, int col) {

if (col 2) {

return false;

} else {

return true;

}

}

//改变某个数据的值

public void setValueAt(Object value, int row, int col) {

if (DEBUG) {

System.out.println("Setting value at " + row + "," + col

+ " to " + value

+ " (an instance of "

+ value.getClass() + ")");

}

if (data[0][col] instanceof Integer

!(value instanceof Integer)) {

try {

data[row][col] = new Integer(value.toString());

fireTableCellUpdated(row, col);

} catch (NumberFormatException e) {

JOptionPane.showMessageDialog(TableDemo.this,"The " + getColumnName(col)

+ " column accepts only integer values.");

}

} else {

data[row][col] = value;

fireTableCellUpdated(row, col);

}

if (DEBUG) {

System.out.println("New value of data:");

printDebugData();

}

}

private void printDebugData() {

int numRows = getRowCount();

int numCols = getColumnCount();

for (int i=0; i numRows; i++) {

System.out.print(" row " + i + ":");

for (int j=0; j numCols; j++) {

System.out.print(" " + data[i][j]);

}

System.out.println();

}

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

}

}

public static void main(String[] args) {

TableDemo frame = new TableDemo();

frame.pack();

frame.setVisible(true);

}

}

求JAVA编程,做一个用户登录系统的设计!

import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ImageIcon;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;@SuppressWarnings("serial")public class MainFrame extends JFrame { JLabel lbl1 = new JLabel("用户名:"); JLabel lbl2 = new JLabel("密 码:"); JTextField txt = new JTextField("admin",20); JPasswordField pwd = new JPasswordField(20); JButton btn = new JButton("登录"); JPanel pnl = new JPanel(); private int error = 0; public MainFrame(String title) throws HeadlessException { super(title); init(); } private void init() { this.setResizable(false); pwd.setEchoChar('*'); pnl.add(lbl1); pnl.add(txt); pnl.add(lbl2); pnl.add(pwd); pnl.add(btn); this.getContentPane().add(pnl); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if ("admin".equals(new String(pwd.getPassword()))){ pnl.removeAll(); JLabel lbl3 = new JLabel(); ImageIcon icon = new ImageIcon(this.getClass().getResource("pic.jpg")); lbl3.setIcon(icon); pnl.add(lbl3); } else{ if(error 3){ JOptionPane.showMessageDialog(null,"密码输入错误,请再试一次"); error++; } else{ JOptionPane.showMessageDialog(null,"对不起,您不是合法用户"); txt.setEnabled(false); pwd.setEnabled(false); btn.setEnabled(false); } } } }); } public static void main(String[] args) { MainFrame frm = new MainFrame("测试"); frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frm.setBounds(100, 100, 300, 120); frm.setVisible(true); }}


当前标题:系统设计代码java 系统设计代码设计
分享链接:http://ybzwz.com/article/doocjeh.html