欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

java編寫通訊錄的代碼,個人通訊錄java代碼

用Java編輯通訊錄

附件:源程序清單 import java.awt.*; import java.awt.event.*; class Info { public static String name,address,mail,telephone; Info(){} } public class addressBook extends Frame implements ActionListener { private MenuItem noteAdd=new MenuItem("Add"); private MenuItem noteDel=new MenuItem("Del"); private MenuItem noteEdit=new MenuItem("Modify"); private MenuItem noteExit=new MenuItem("Exit"); private List noteList=new List(); private String[][] message=new String [1000][4]; public Info notes=new Info(); public addressBook(){ super("通訊錄 向陽"); Menu note=new Menu("Edit"); note.add(noteAdd); note.add(noteDel); note.add(noteEdit); note.addSeparator(); note.add(noteExit); MenuBar bar=new MenuBar(); bar.add(note); setMenuBar(bar); add(noteList); noteAdd.addActionListener(this); noteDel.addActionListener(this); noteEdit.addActionListener(this); noteExit.addActionListener(this); noteList.addActionListener(this); addWindowListener(new WindowCloser()); setSize(300,400); show(); } public void actionPerformed(ActionEvent e){ if(e.getSource()==noteAdd){ notes.mail=null; notes.name=null; notes.address=null; notes.telephone=null; int index=noteList.getItemCount(); EditDialog dlg=new EditDialog(this,"添加通訊錄"); if(dlg.isOk){ message[index][0]=dlg.textName.getText(); message[index][1]=dlg.textAddress.getText(); message[index][2]=dlg.textEmail.getText(); message[index][3]=dlg.textTelephone.getText(); if (message[index][0]!=null){ String s="姓名:"+message[index][0]+";\t地址"+message[index][1]+";\tE-mail"+message[index][2]+";\t電話"+message[index][3]; noteList.add(s); } } dlg.dispose(); }else if(e.getSource()==noteDel){ ConfirmDialog dlg=new ConfirmDialog(this,"確認刪除","確定要刪除這一條嗎?"); if (dlg.close){ noteList.remove(noteList.getSelectedIndex()); } dlg.dispose(); }else if(e.getSource()==noteEdit||e.getSource()==noteList){ int i=noteList.getSelectedIndex(); if(i!=-1){ notes.name=message[i][0]; notes.address=message[i][1]; notes.mail=message[i][2]; notes.telephone=message[i][3]; EditDialog dlg=new EditDialog(this,"修改通訊錄"); if(dlg.isOk){ message[i][0]=dlg.textName.getText(); message[i][1]=dlg.textAddress.getText(); message[i][2]=dlg.textEmail.getText(); message[i][3]=dlg.textTelephone.getText(); String s="姓名:"+message[i][0]+";\t地址"+message[i][1]+";\tE-mail"+message[i][2]+";\t電話"+message[i][3]; noteList.replaceItem(s,i); } dlg.dispose(); } }else if(e.getSource()==noteExit){ System.exit(0); } } private class WindowCloser extends WindowAdapter{ public void WindowClosing(WindowEvent we){ System.exit(0); } } public static void main(String[]args){ addressBook a=new addressBook(); } } class EditDialog extends Dialog implements ActionListener { private Button ok=new Button("確定"); private Button cancel=new Button("取消"); private Label labelName=new Label("姓名",Label.LEFT); private Label labelAddress=new Label("地址",Label.LEFT); private Label labelEmail=new Label("E-mail",Label.LEFT); private Label labelTelephone=new Label("電話",Label.LEFT); TextField textName=new TextField(30); TextField textAddress=new TextField(30); TextField textEmail=new TextField(30); TextField textTelephone=new TextField(30); public boolean isOk=false; private Info notes=new Info(); public EditDialog(Frame parent,String title){ super(parent,title,true); Panel pName=new Panel(); pName.setLayout(new FlowLayout()); pName.add(labelName); pName.add(textName); Panel pAddress=new Panel(); pName.setLayout(new FlowLayout()); pName.add(labelAddress); pName.add(textAddress); Panel pEmail=new Panel(); pName.add(labelEmail); pName.add(textEmail); Panel pTelephone=new Panel(); pName.add(labelTelephone); pName.add(textTelephone); Panel pInfo=new Panel(); pInfo.setLayout(new GridLayout(4,1)); pInfo.add(pName); pInfo.add(pAddress); pInfo.add(pEmail); pInfo.add(pTelephone); Panel pButton=new Panel(); pButton.setLayout(new FlowLayout()); pButton.add(ok); pButton.add(cancel); setLayout(new BorderLayout()); add("Center",pInfo); add("South",pButton); textName.setText(notes.name); textAddress.setText(notes.address); textEmail.setText(notes.mail); textTelephone.setText(notes.telephone); ok.addActionListener(this); cancel.addActionListener(this); addWindowListener(new WindowCloser()); setResizable(false); pack(); show(); } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==ok){ isOk=true; this.hide(); } if(ae.getSource()==cancel){ isOk=false; this.hide(); } } private class WindowCloser extends WindowAdapter { public void windowClosing(WindowEvent we) { isOk=false; EditDialog.this.hide(); } } } class ConfirmDialog extends Dialog implements ActionListener { private Button okay=new Button("確定"); private Button cancel=new Button("取消"); private Label label=new Label(); public boolean close=false; public ConfirmDialog (Frame parent,String title,String question) { super(parent,title,true); label.setText(question); Panel buttons=new Panel(); buttons.setLayout(new FlowLayout()); buttons.add(okay); buttons.add(cancel); setLayout(new BorderLayout()); add("Center",label); add("South",buttons); okay.addActionListener(this); cancel.addActionListener(this); addWindowListener(new WindowCloser()); setResizable(false); pack(); show(); } private class WindowCloser extends WindowAdapter{ public void WindowClosing(WindowEvent we){ ConfirmDialog.this.close=false; ConfirmDialog.this.hide(); } public void actionPerformed(ActionEvent ae){ close=(ae.getSource()==okay); hide(); } }}

創(chuàng)新互聯(lián)公司服務項目包括順城網(wǎng)站建設、順城網(wǎng)站制作、順城網(wǎng)頁制作以及順城網(wǎng)絡營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關系等,向廣大中小型企業(yè)、政府機構等提供互聯(lián)網(wǎng)行業(yè)的解決方案,順城網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務的客戶以成都為中心已經(jīng)輻射到順城省份的部分城市,未來相信會繼續(xù)擴大服務區(qū)域并繼續(xù)獲得客戶的支持與信任!

輸入3位數(shù)字 在通訊錄中找到跟前3位數(shù)字相匹配的手機號碼,用java怎么寫代碼?

樓上應該放出答案了,我這里只是用其他界面顯示,不懂Swing的可以略過,(代碼比較粗略,不一定符合規(guī)范,照搬需謹慎)

import?java.awt.Dimension;

import?java.awt.GridLayout;

import?java.awt.event.KeyAdapter;

import?java.awt.event.KeyEvent;

import?java.util.ArrayList;

import?java.util.List;

import?javax.swing.JFrame;

import?javax.swing.JLabel;

import?javax.swing.JTextField;

public?class?Demo?extends?JFrame?{

ListString?pnos?=?new?ArrayListString();

public?static?void?main(String[]?args)?{

new?Demo();

}

public?Demo()?{

StringBuffer?sb?=?new?StringBuffer("htmlbody");

while?(pnos.size()??15)?{//?"隨機"生成電話號碼,可以不理他

String?telString?=?getRandomTel();

if?(!pnos.contains(telString))?{

pnos.add(telString);

sb.append(telString);

if?(pnos.size()?%?3?==?0)?{

sb.append("br/");

}?else?if?(pnos.size()??15)?{

sb.append(",");

}

}

}

sb.append("/body/html");

JLabel?label?=?new?JLabel(sb.toString());

final?JTextField?input?=?new?JTextField();

final?JLabel?result?=?new?JLabel();

this.setLayout(new?GridLayout(3,?1));

this.add(label);

this.add(input);

this.add(result);

this.setSize(new?Dimension(300,?500));

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

this.setLocationRelativeTo(null);

this.setVisible(true);

input.addKeyListener(new?KeyAdapter()?{

@Override

public?void?keyReleased(KeyEvent?keyevent)?{

result.setText(getMatchNo(input.getText()));

}

});

}

/**

?*?

?*?@param?perfix

?*?@return

?*/

public?String?getMatchNo(String?perfix)?{

StringBuffer?sb?=?new?StringBuffer("htmlbody");

if?(perfix?!=?null??!perfix.trim().equals(""))

for?(String?string?:?pnos)?{//?這里是你要的部分,遍歷“號碼本”匹配是否為輸入數(shù)字的開頭

if?(string.startsWith(perfix))?{

sb.append(string).append("br/");

}

}

sb.append("/body/html");

return?sb.toString();

}

private?static?String[]?telFirst?=?"134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153"

.split(",");

private?static?String?getRandomTel()?{

int?index?=?getNum(0,?telFirst.length?-?1);

String?first?=?telFirst[index];

String?second?=?String.valueOf(getNum(1,?888)?+?10000).substring(1);

String?thrid?=?String.valueOf(getNum(1,?9100)?+?10000).substring(1);

return?first?+?second?+?thrid;

}

public?static?int?getNum(int?start,?int?end)?{

return?(int)?(Math.random()?*?(end?-?start?+?1)?+?start);

}

}

用JAVA編寫一個班級通訊錄

1)java form,jlable 、textField、button 神馬 的 GridBagLayout布局搞一發(fā)

2)JDBC 往數(shù)據(jù)庫搞一搞;

3)數(shù)據(jù)庫排序取出,或者取出后代碼排個序

4)步驟2已經(jīng)寫入數(shù)據(jù)庫,下次從數(shù)據(jù)庫區(qū),不會丟失

5)搞一個方法,專門用于顯示,每計算一次,調用這個方法

另;應該搞個登陸的,管理總要有權限控制的

Java編寫一個班級通訊錄

import?java.util.ArrayList;

import?java.util.List;

import?java.util.Scanner;

public?class?AddressList?{

static?Scanner?scanner?=?new?Scanner(System.in);

static?ListEntity?enlist?=?new?ArrayListEntity();

public?static?void?main(String[]?args)?{

int?input;

AddressList?addre?=?new?AddressList();

System.out.println("===============歡迎使用**通訊錄===============");

do{

System.out.println("1、插入聯(lián)系人");

System.out.println("2、刪除練習人");

System.out.println("3、修改聯(lián)系人");

System.out.println("4、查詢練習人");

System.out.println("5、查詢?nèi)柯?lián)系人");

System.out.println("0、退出系統(tǒng)");

System.out.println("請選擇:");

input?=?scanner.nextInt();

switch(input){

case?1:

Entity?e?=?new?Entity();

e.id?=?enlist.size();

System.out.println("請輸入聯(lián)系人姓名:");

e.name?=?scanner.next();

System.out.println("請輸入聯(lián)系方式:");

e.number?=?scanner.nextInt();

addre.add(e);

System.out.println("插入成功!");

break;

case?2:

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

int?num?=?scanner.nextInt();

if(addre.delete(num))

System.out.println("刪除成功!");

else

System.out.println("刪除失敗,請確認信息是否正確!");

break;

case?3:

System.out.println("請輸入要修改人編號:");

int?unum?=?scanner.nextInt();

addre.update(unum);

System.out.println("修改完成!");

break;

case?4:

System.out.println("請輸入要查詢?nèi)诵彰?);

String?name?=?scanner.next();

Entity?ent?=?addre.select(name);

if(ent!=null){

System.out.println(name+"的聯(lián)系方式為:"+ent.number);

}else{

System.out.println("查無此人!");

}

break;

case?5:

for(Entity?entit:enlist){

System.out.println(entit.name+"的聯(lián)系方式為:"+entit.number);

}

break;

}

}while(input!=0);

System.out.println("謝謝使用!");

}

/*

?*?添加聯(lián)系人

?*/

public?boolean?add(Entity?e){

enlist.add(e);

return?true;

}

/*

?*?刪除聯(lián)系人

?*/

public?boolean?delete(int?num){

if(numenlist.size())

return?false;

else

enlist.remove(num);

return?true;

}

/*

?*?修改聯(lián)系人

?*/

public?void?update(int?num){

if(numenlist.size())

System.out.println("查無此人!");

else{

Entity?e?=?new?Entity();

e.id?=?num;

System.out.println("請輸入聯(lián)系人姓名:");

e.name?=?scanner.next();

System.out.println("請輸入聯(lián)系方式:");

e.number?=?scanner.nextInt();

enlist.set(num,?e);

}

}

/*

?*?查詢指定聯(lián)系人電話

?*/

public?Entity?select(String?name){

Entity?en?=?null;

for(Entity?e?:?enlist){

if(e.name.equals(name))

en?=?e;

}

return?en;

}

}

class?Entity{

public?int?id;//編號

public?String?name;//姓名

public?int?number;//聯(lián)系電話

}

(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通訊錄全部代碼!

import java.io.BufferedOutputStream;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.IOException;

import java.io.PrintWriter;

import java.util.Scanner;

public class AddList {

private String filePath = "";

private String bakPath = "";

private String content = "";

Scanner sc = new Scanner(System.in);

public String readFile(){

content = "";

if (isNull(filePath)) {

System.out.println("文件存儲路徑:");

filePath = sc.nextLine();

}

File file = new File(filePath);

FileReader fr = null;

try {

if (file.exists()) {

fr = new FileReader(file);

char[] chars = new char[1024];

int n = 0;

while((n = fr.read(chars)) != -1){

String string = new String(chars, 0, n);

content = content + string;

}

} else {

System.out.println("文件不存在");

}

} catch (Exception e) {

e.printStackTrace();

} finally {

if (fr != null) {

try {

fr.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

return content;

}

public void writeFile(String path){

File file = new File(path);

FileOutputStream fos = null;

mkDirs(path);

try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bos, true);

pw.print(content);

pw.flush();

} catch (FileNotFoundException e) {

e.printStackTrace();

} finally {

if (fos != null) {

try {

fos.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

public void writeFile(){

if (isNull(filePath)) {

System.out.println("文件存儲路徑:");

filePath = sc.nextLine();

}

File file = new File(filePath);

FileOutputStream fos = null;

mkDirs(filePath);

try {

fos = new FileOutputStream(file);

BufferedOutputStream bos = new BufferedOutputStream(fos);

PrintWriter pw = new PrintWriter(bos, true);

pw.print(content);

pw.flush();

} catch (FileNotFoundException e) {

e.printStackTrace();

} finally {

if (fos != null) {

try {

fos.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}

}

public void mkDirs(String filepath){

if (filepath.indexOf("\\") != -1) {

filepath = filepath.replaceAll("\\", "/");

}

int n = filepath.indexOf("http://");

String path = filepath.substring(0, n) + "http://";

filepath = filepath.substring(filepath.indexOf("http://") + 1, filepath.length());

String[] files = filepath.split("/");

for (int i = 0; i files.length - 1; i++) {

path = path + files[i];

File file = new File(path);

if (!file.exists()) {

file.mkdir();

}

}

}

public void addImfor(){

System.out.println("--------增加記錄---------");

String name = "";

String tel = "";

String email = "";

content = readFile();

while(true){

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

name = sc.next();

System.out.println("電話:");

tel = sc.next();

System.out.println("Email:");

email = sc.next();

content = content + name + "" + tel + "" + email +"==";

System.out.println("0、Exit 1、繼續(xù)");

int i = sc.nextInt();

if (i == 0) {

break;

}

}

writeFile();

}

public void deleteImfor(){

System.out.println("---------刪除記錄---------");

String name = "";

String[] imfors = null;

content = readFile();

while(true){

System.out.println("你要刪除的姓名是:");

name = sc.next();

if (content.indexOf(name) != -1) {

imfors = content.split("==");

for (int i = 0; i imfors.length; i++) {

if (imfors[i].indexOf(name) != -1) {

imfors[i] = "";

}

}

網(wǎng)頁標題:java編寫通訊錄的代碼,個人通訊錄java代碼
網(wǎng)頁路徑:http://chinadenli.net/article28/heipcp.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設、App設計、標簽優(yōu)化、網(wǎng)站設計網(wǎng)站制作、自適應網(wǎng)站

廣告

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

營銷型網(wǎng)站建設