Java--Address Book Management System【Course Design】

Table of contents

1 Design task

1.1 Demand Analysis

1.2 Task Analysis

2 System Analysis

2.1 Overall Design Analysis

2.1.1 Design requirements

2.1.2 Design tasks

2.1.3 Design ideas

2.2 Feasibility analysis

2.2.1 Technical Feasibility Analysis

2.2.2 Economic Feasibility Analysis

2.2.3 Operation Feasibility Analysis

2.3 Functional structure analysis

3 System Design

4 System Implementation

5 System Test

5.1 Create a new contact

5.2 Modify contacts

5.3 Query contacts

5.3.1 Display saved contacts

5.3.2 Find Contacts

5.4 Save contacts

5.5 Delete contacts

6 Design summary and experience

references


1 design task

1.1 Demand Analysis

The application of the address book in today's daily work is very popular. Everyone has a large amount of address book information. At present, everyone generally records all the address book information manually. However, with the development of the times, people's contact methods and information have become complex and diverse, and the information in the address book has increased greatly, making it difficult to manage these information materials. Directly operate to find, add, modify, delete these information, due to the large amount of data, the workload is very huge, it is very difficult to search and edit, and it is very error-prone, which may easily cause confusion or loss of data. In all kinds of mobile phones, although the phone book built in the morning pass is convenient to carry, it has the disadvantages of "less records, small interface, inconvenient browsing, and incomplete recorded information". Some people use Excel or Word to compile the address book. Although the data is relatively comprehensive and the information is relatively sufficient, it is extremely inconvenient to search and troublesome to maintain. Therefore, it is necessary to use file or database technology to establish an address book management system. The data management work is standardized, systematized, and proceduralized to avoid confusion in data management. Improve the speed and accuracy of information processing, and be able to query and modify the address book in a timely, accurate and effective manner.

1.2 Task Analysis

The address book management system will provide a good platform for the modern management of personal information contact. It is also a management software developed for a large amount of information processing among people. The interaction between people is more frequent. Using JDK1.7.0 and NetBeans6.9.1 software, we design and realize the graphical user interface, in which the management of our own contact information is aimed at improving our work efficiency. After various thinking and inquiries, we design a Corresponding functions of the address book management system. Address book management includes functions such as input, query, maintenance and output of contact information.

2 System Analysis

2.1 Overall Design Analysis

2.1.1 Design requirements

The address book includes the basic information in the general address book, and also needs to realize the ordinary retrieval function. By writing the contacts into the file, when the program is executed, it needs to import data from the file, and save the data file to the file after the program exits. .

2.1.2 Design tasks

Enter contact information; query contacts; delete specified contact information; exit the address book management system.

2.1.3 Design ideas

The main class of a program is to enter the system and carry out the interface design of graphic interaction; by establishing and using the ArrayList dynamic array and combining the operation mode of file input and output streams, add, search, delete, etc.: add, search, delete, and exit through buttons The addActionListener0 method implements event ringing.

Create a file input stream on the standard input stream through FileDescriptor, then read data through keyboard input, and put the read data into the specified file "readfromkeyboard.txt" and then create an input stream of the file, and output it on standard output through FileDescriptor The file output stream established on the stream displays the data in the file on the screen.

2.2 Feasibility Analysis 

The feasibility of the system is to use the lowest cost to determine whether the system function can be realized in a very short period of time. It cannot rely on guesswork but detailed analysis reports to analyze whether the system is feasible and the feasibility of the system from all levels. Analysis is to simplify the design process and analyze the process of the system in an abstract way, so as to save costs and improve the stability of the system, reduce the workload of design to save costs to a certain extent, and achieve twice the result with half the effort.

Feasibility analysis is through the main content and supporting conditions of the project. The feasibility analysis process is the process of determining whether a system is worth developing.

2.2.1 Technical Feasibility Analysis

After studying the Java course for one , the team members have basically mastered the semantics and syntax of the Java language. This system mainly relies on the Java language to realize. If you encounter problems, you can also search for information in the library or on the Internet, and study independently. technically possible.

2.2.2 Economic Feasibility Analysis

The system is written in the Java language, and it only needs a device with Java compilation function to run it. Since the system only involves the simple management of address book information , and due to the limited learning experience of the team members, it has not yet been connected to the database. After joining the database later, it will also Only need to rent a server, and the operation cost of the database. Economically feasible.

2.2.3 Operation Feasibility Analysis

The operation interface of this system is very simple and easy to operate. Both the user and the administrator can perform a series of operations through the keyboard according to the prompts of the system, and master all the operations of the system in a short time.

In the address book system, contacts can be classified, such as family members, friends, classmates, etc. After being divided into groups, members can be added to each group accordingly. At the same time, groups can be continuously added, modified or deleted to meet user needs. When users need to query contacts, they can directly obtain contact information by searching names, or query contacts in groups. This system has greatly improved the working efficiency of the inquiry, and improved more convenience for the user. Therefore, operationally it works.

2.3 Functional  structure analysis

(1) Add contact information: When the user selects this function in the main interface menu, he will enter the entry interface. After the user enters various contact information in the input interface, the system will collect the contact information in the interface.

(2) Query contacts: When the user selects this function in the main interface menu, he will enter the query interface. The system provides users with complete information query and fuzzy query functions. After the user enters the name of the contact in the query interface, the system will query the contact information table as required, and display the queried contact information in the list.

(3) Modify contacts: When the user selects this function in the main interface menu, the user enters the modification interface 1, first completes the contact information query according to the user input information, and after the user selects the contact to be modified in the list, enters the modification interface 2. After the user finishes modifying the contact information in the modification interface 2, the system modifies the corresponding record after collecting the information in the interface 2.

(4) Delete contact: When the user selects this function in the main interface menu, the delete interface will be entered. First, complete the query of contact information according to the information entered by the user. After the user selects the contact to be deleted in the list, the system deletes the corresponding record of the contact information.

3 system design

Infro class:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public 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<Infro> 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:"+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("输入Id号:");
		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集合长度加一
			}
		}
	
	//删除
	public static void deleteFunction(){
		System.out.println("输入要删除的联系人的编号");
		Scanner in_2 = new Scanner(System.in);
		String d1 = in_2.nextLine();
		java.util.Iterator<Infro> 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<len;a++){
			if(s1.equals(list.get(a).name)){
				System.out.println(list.get(a).toString());
				}
			}
		}
	
	//显示
	public static void showFunction(){
		for(int i = 0 ;i<len;i++){
			System.out.println(list.get(i).toString());
			}
		}
	
	//保存
	public static void writeFunction() throws IOException{
		FileWriter writer = new FileWriter("通讯录管理.txt");
		for(int i = 0 ;i<len;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();
		}
	}

Demo class:

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;
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);
		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("", "", "", "", "", "");
		}
	}

4 System Implementation

The overall implementation code of the address book management system is running normally, and the overall operation effect diagram is shown in Figure 4.1:

Figure 4.1 The overall operation effect diagram of the address book management system

5  system test

5.1 Create a new contact

After using it, the user can directly select a new contact to add information, as shown in Figure 5.1:

Figure 5.1 Create a new contact

5.2 Modify contacts

After the user logs in to the system, he can choose to edit contacts in the main function mode of the system, as shown in Figure 5.2:

Figure 5.2 Modify Contact

5.3 Query contacts

5.3.1 Display saved contacts

After the user logs in to the system, he can choose to display the saved contact query in the main function mode of the system, as shown in Figure 5.3:

Figure 5.3 Saved Contact Query

5.3.2 Find Contacts

After the user logs in to the system, he can choose to search for contacts by name in the main function mode of the system, as shown in Figure 5.4:

Figure 5.4 Find Contact Query 

5.4 Save contacts

After the user logs in to the system, he can choose to save and view the saved contacts in the main function mode of the system, as shown in Figure 5.5:

Figure 5.5 Save and view saved contacts

5.5 Delete contacts

After the user logs in to the system, he can choose to delete contacts in the main function mode of the system.

6 Design summary and experience

Increased awareness. Members of this group have never written code with a particularly long number of lines, thinking that there is no need for various analysis, but in this course design, everyone deeply felt the importance of analysis. Without a general plan, it will lead to confusion in thinking and program errors. It is not convenient for others to read and write, and it is also not convenient for members of the team to find and correct mistakes, so this is why it takes effort to analyze and design at the beginning.

Progress in thinking. A good program requires strong programming ability, but also a good thinking ability, which determines whether the code has a high utilization rate, and the high utilization rate of the code can save a lot of reading time. It is not only convenient to change the code, but also saves time. space and reduce running time.

The improvement of basic knowledge and skills. Object-oriented thinking is one of the basic guiding ideologies in the programming world, which enables programmers to design programs in a way close to the real world, rather than just considering the data to be processed and the realization of functions. In this way, we can abstract the objects we need to operate in the program into classes, and set properties and methods for them according to our needs. The data exchange in the program can be abstracted as communication between objects. This idea hides a lot of The details allow us to quickly build the framework of the program and achieve rapid development. Object-based programs are also very scalable and have excellent maintainability.

In short, this course design has enabled the members of this group to gain a lot, learn a lot, and be more patient than before. Thanks to the school and teachers for giving the members of this group the opportunity to design this course. During the course design process, we have learned a lot, cultivated our ability to work independently, and established confidence in our own ability. Learning work life has very important implications. Moreover, the hands-on ability has been greatly improved, and we have fully experienced the difficulty of exploring and the joy of success in the process of creation. Due to our limited knowledge and ability, there are still many problems and deficiencies in many aspects, and the consideration is not very sufficient. There is still a certain distance between this design and reality, and it needs to be continuously supplemented and perfected. Here, I am also very grateful to the teacher for his guidance and help.

references

[1] Rong Yuzhi. Design and Implementation of Contact Management System [J]. Chizi (First and Middle), 2017(05): 175.

[2] Luo Xiaochao. Design and Implementation of Contact Management System for Private Colleges [D]. Southwest Jiaotong University, 2018.

[3] Liu Yi. A Preliminary Study on Ideological and Political Case Teaching of Advanced Java Programming Courses [J]. Computer Age, 2020(12): 85-87+90.

[4] Yang Ting, Guo Hui, Ren Hongde. Exploration and Practice of Java Programming Ability Cultivation [J]. Industry and Information Technology Education, 2020(11):89-92.

[5] Chen Suqing. Research on Experimental Teaching of Java Programming Course [J]. Fujian Computer, 2020,36(11):176-177.

[6] Pengfei, Ma Zongbao. A Modular Workflow Engine Method for Lightweight Java Client Distributed Services [J]. Electronic Design Engineering, 2020, 28(22): 160-164+169.

[7] Wang Yuqing. Design and Implementation of Contact Query System Based on Java [J]. Information and Computer (Theoretical Edition), 2021,33(02):138-140.

[8] Xu Lianxia, ​​Fu Wei. Design and Implementation of Contact Management System [J]. Digital World, 2019(09):95-96.

[9] Han Jiying. Design and Implementation of Data Visualization Based on JAVA [J]. Science and Technology Innovation, 2020(32):89-90.

[10] Duan Shali. Talking about JAVA collection framework and its application [J]. Information Technology and Informatization, 2020 (10): 104-106.

Guess you like

Origin blog.csdn.net/weixin_65089091/article/details/128244905