Java implementation of simple console address book
The sub menus at all levels are controlled through the main menu, and the functions of adding records, finding records, deleting records, modifying records, sorting records, and exiting the system are realized. A total of six functional modules.
The above figure shows the functions of each module, and also uses regular expressions to judge whether the input meets the rules. This system reflects the MVC design pattern, and the division of labor and calls is very clear.
It mainly includes the following classes:
App class: the main function class of the program, the entry menu class at the beginning of the program: there are simple page display effects, and there is no function implementation. Telnoteregex class: regular expressions, which determine whether the input is qualified, are all in this method. Operate class: business logic class. The implementation of all functions is basically concentrated in this class. Person class: encapsulates data.
Specific implementation code:
Implementation code of APP class:
Specific implementation code of person class:
Telnoteregex class specific code:
Specific implementation of menu class code:
Specific implementation of operate class:
Summary: this project makes it clear to me what is object-oriented and why Java is an object-oriented programming language. The code of the program is called by objects. I also understand how a project should be written with a clear division of labor. The functions and views should be separated. Each class has its own specific functions. The functions of each class should not be unloaded from each other, The reuse of such codes is basically not high. If they are clearly separated, when adding function modules in the future, they only need to add functions without modifying the previous code, which well reflects the opening and closing principle. For function development and modification, this project also reflects the MVC design mode. For me, this project has benefited me a lot.