java通訊錄系統(tǒng)代碼 javaee通訊錄系統(tǒng)

javaweb 做一個通訊錄的小項目 求源代碼 急求。

先設計數(shù)據(jù)庫中通訊錄表格(字段有:id,聯(lián)系人姓名,手機號,備注),然后,hebinate實現(xiàn)數(shù)據(jù)庫表到javabean的映射,同時也會生成對通訊錄表格的增刪改查的基本sql語句對應的接口。然后你再寫一個Servlet,連接頁面自己數(shù)據(jù)庫操作接口即可

創(chuàng)新互聯(lián)建站專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務,包含不限于成都網(wǎng)站制作、成都做網(wǎng)站、隆昌網(wǎng)絡推廣、成都微信小程序、隆昌網(wǎng)絡營銷、隆昌企業(yè)策劃、隆昌品牌公關、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運營等,從售前售中售后,我們都將竭誠為您服務,您的肯定,是我們最大的嘉獎;創(chuàng)新互聯(lián)建站為所有大學生創(chuàng)業(yè)者提供隆昌建站搭建服務,24小時服務熱線:18980820575,官方網(wǎng)址:muchs.cn

(java編程)采用雙向鏈表作數(shù)據(jù)結構,編寫一個通訊錄管理系統(tǒng)。

#include

#include

#include

using namespace std;

#define SIZE 10

struct AddrList

{

string name;

string sex;

int age;

string QQ;

}addrlist[SIZE];

int main()

{

int i;

int j;

cout"輸入要輸入的記錄數(shù)量:";

cini;

if (iSIZE)

{

cout"輸入的記錄數(shù)量大于順序表的最大長度!"endl;

return 0;

}

cout"輸入格式:\n姓名 性別 年齡 QQ\n"endl;

for (j=0;ji;++j)

{

cout"輸入第"j+1"條記錄"endl;

cinaddrlist[j].nameaddrlist[j].sexaddrlist[j].ageaddrlist[j].QQ;

}

cout"\n姓名\t性別\t年齡\tQQ"endl;

for (j=0;ji;++j)

{

coutaddrlist[j].name"\t"addrlist[j].sex"\t"addrlist[j].age"\t"addrlist[j].QQendl;

}

return 0;

}

輸入:2

張三 男 23 123456

李四 女 24 66666

java通訊錄管理系統(tǒng)設計代碼怎么編譯

java編寫這個通訊錄管理系統(tǒng)

java編寫這個通訊錄管理系統(tǒng)_Java如何實現(xiàn)通訊錄管理系統(tǒng)

咕嚕嚕在芬蘭

原創(chuàng)

關注

3點贊·2305人閱讀

Java如何實現(xiàn)通訊錄管理系統(tǒng)

發(fā)布時間:2020-07-28 09:39:42

來源:億速云

閱讀:65

作者:Leah

這篇文章將為大家詳細講解有關Java如何實現(xiàn)通訊錄管理系統(tǒng),文章內容質量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關知識有一定的了解。

本文實例為大家分享了java實現(xiàn)通訊錄管理系統(tǒng)的具體代碼,供大家參考,具體內容如下

完成項目的流程:

1.根據(jù)需求,確定大體方向

2.功能模塊分析

3.界面實現(xiàn)

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();

//構造函數(shù)

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("請輸入添加的數(shù)據(jù):");

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("數(shù)據(jù)添加失敗啦");

}else{

System.out.println("數(shù)據(jù)添加成功啦");

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

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

}

}

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

// System.out.println("輸入要刪除的聯(lián)系人的編號");

// 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("輸入要刪除的聯(lián)系人的編號");

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;//一定要加這個,否則當做了刪除操作再做添加操作的時候會出現(xiàn)異常(類似于指針,棧)

System.out.println("刪除完畢"+"此時通訊錄記錄條數(shù)為:" + --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("數(shù)據(jù)修改完畢");

}

}

}

/**

* 查詢功能

**/

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("成功寫入一行數(shù)據(jù)到 通訊錄管理.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("新建聯(lián)系人");

JButton button2 = new JButton("刪除聯(lián)系人");

JButton button3 = new JButton("編輯聯(lián)系人");

JButton button4 = new JButton("查找聯(lián)系人");

JButton button5 = new JButton("顯示所有聯(lián)系人");

JButton button6 = new JButton("保存聯(lián)系人到本地");

JButton button7 = new JButton("讀取本地聯(lián)系人");

jp.setLayout(new GridLayout(2,4,5,5));//新建網(wǎng)格布局管理器(行數(shù),列數(shù),組件間的水平垂直間距)

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("*通 訊 錄 管 理 系 統(tǒng)*");

setVisible(true);

setResizable(false);//窗體大小由程序員決定,用戶不能自由改變大小

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

/**

*按鍵響應

*

**/

button1.addActionListener(new ActionListener(){//添加功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.addFunction();

}

});

button2.addActionListener(new ActionListener(){//刪除功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.deleteFunction();

}

});

button3.addActionListener(new ActionListener(){//修改功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.reditFunction();

}

});

button4.addActionListener(new ActionListener(){//查詢功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

try {

Infro.searchFunction();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

});

button5.addActionListener(new ActionListener(){//顯示功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

Infro.showFunction();

}

});

button6.addActionListener(new ActionListener(){//保存功能實現(xiàn)

public void actionPerformed(ActionEvent arg0){

try {

Infro.writeFunction();

} catch (IOException e) {

e.printStackTrace();

}

}

});

button7.addActionListener(new ActionListener(){//讀取功能實現(xiàn)

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如何實現(xiàn)通訊錄管理系統(tǒng)就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

實現(xiàn)一個小型通訊錄。Java

Friend類:public class Friend {

/*

* 姓名

*/

private String name;

/*

* 電話

*/

private String telephone;

/*

* 郵箱

*/

private String email;

/*

* 公司

*/

private String company; public String getName() {

return name;

} public void setName(String name) {

this.name = name;

} public String getTelephone() {

return telephone;

} public void setTelephone(String telephone) {

this.telephone = telephone;

} public String getEmail() {

return email;

} public void setEmail(String email) {

this.email = email;

} public String getCompany() {

return company;

} public void setCompany(String company) {

this.company = company;

} public String toString() {

StringBuffer str = new StringBuffer(); str.append("姓名:" + name).append("\n");

str.append("電話:" + telephone).append("\n");

str.append("郵箱:" + email).append("\n");

str.append("公司:" + company).append("\n");

str.append("-----------------------------------------\n");

return str.toString();

}

}AddFriend類:public class AddFriend { /**

* 主方法 程序的入口

*/

public static void main(String[] args) {

ListFriend friendList = new ArrayListFriend();

char isGo = 'Y';

int i = 0;

do {

Friend friend = new Friend();

System.out.println("請輸入第" + (i + 1) + "位朋友的姓名:");

InputStreamReader reader = new InputStreamReader(System.in);

String str = "";

try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setName(str); System.out.println("請輸入第" + (i + 1) + "位朋友的電話:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

if (str.matches("\\d*") str.length() == 11) {// 判斷用戶輸入的電話是否符合標準

friend.setTelephone(str);

} else {

System.out.println("電話號碼輸入有誤,請重新輸入!");

continue;

} System.out.println("請輸入第" + (i + 1) + "位朋友的郵箱:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setEmail(str); System.out.println("請輸入第" + (i + 1) + "位朋友的公司:"); try {

str = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

friend.setCompany(str); friendList.add(friend); i++; System.out.println("是否繼續(xù)添加?(Y/N):");

String go = "";

try {

go = (new BufferedReader(reader)).readLine();

} catch (IOException e) {

e.printStackTrace();

}

isGo = go.charAt(0);

} while (isGo == 'Y' || isGo == 'y'); for (int j = 0; j friendList.size(); j++) {

System.out.println(friendList.get(j).toString());

}

}

}

名稱欄目:java通訊錄系統(tǒng)代碼 javaee通訊錄系統(tǒng)
URL網(wǎng)址:http://muchs.cn/article36/ddcdjpg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供微信小程序、外貿(mào)網(wǎng)站建設App設計、建站公司網(wǎng)站營銷、企業(yè)網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設計公司