Go-客户信息关系系统的实现

目录
  • 项目需求分析
  • 项目的界面设计
    • 主菜单界面
    • 添加客户界面
    • 删除客户界面
    • 客户列表界面
  • 客户关系管理系统的程序框架图
  • 项目功能实现-显示主菜单和完成退出软件功能
  • 项目功能实现-完成显示客户列表的功能
  • 项目功能实现-添加客户的功能
  • 项目功能实现-完成删除客户的功能

项目需求分析

  1. 模拟实现基于文本界面的《客户信息管理软件》。
  2. 该软件能够实现对客户对象的插入、修改和删除(用切片实现),并能够打印客户明细表

项目的界面设计

主菜单界面

添加客户界面

删除客户界面

客户列表界面

客户关系管理系统的程序框架图

项目功能实现-显示主菜单和完成退出软件功能

代码实现 customerManage/model/customer.go

package model

//声明一个 Customer 结构体,表示一个客户信息
type Customer struct{
	Id int
	Name string
	Gender string
	Age int
	Phone string
	Email string
}
//使用工厂模式,返回一个 Customer 的实例
func NewCustomer(id int,name string,gender string,age int,phone string,email string)Customer{
	return Customer{
		Id:id,
		Name:name,
		Gender:gender,
		Age:age,
		Phone:phone,
		Email:email,
	}
}

customerManage/service/customerService.go

package service

import "go_code/go_code/chapter13/customerManage/model"

type CustomerService struct{
	customers []model.Customer
	//声明一个字段,表示当前切片含有多少个客户
	//该字段后面,还可以作为新客户的 id+1
	customerNum int
}

customerManage/view/customerView.go

package main

import "fmt"

type customerView struct{
	//定义必要字段
	key string//接收客户输入...
	loop bool//表示是否循环的显示主菜单
	//customerService *service.CustomerService
}
//显示主菜单
func (this *customerView) mainMenu(){
	for {
		fmt.Println("--------客户信息管理软件--------")
		fmt.Println("        1、添加客户")
		fmt.Println("        2、修改客户")
		fmt.Println("        3、删除客户")
		fmt.Println("        4、客户列表")
		fmt.Println("        5、退出")
		fmt.Println()
		fmt.Println("        请选择(1-5):")

		fmt.Scanln(&this.key)

		switch this.key {
		case "1":
			fmt.Println("添加客户")
		case "2":
			fmt.Println("修改客户")
		case "3":
			fmt.Println("删除客户")
		case "4":
			fmt.Println("客户客户")
		case "5":
			this.loop=false
		default:
			fmt.Println("你的输入有误,请重新输入...")
		}

		if !this.loop{
			break
		}

		fmt.Println("你退出了客户管理系统...")

	}
}

func main(){
	//在 main 函数中,创建一个 customerView,并运行显示主菜单..
	customerView:=customerView{
		key:"",
		loop:true,
	}
	//显示主菜单
	customerView.mainMenu()
}

项目功能实现-完成显示客户列表的功能

customerManage/view/customerView.go

package main

import (
	"fmt"
	"go_code/go_code/chapter13/customerManage/service"
)

type customerView struct {
	//定义必要字段
	key  string //接收客户输入...
	loop bool   //表示是否循环的显示主菜单
	//增加一个字段 customerService
	customerService *service.CustomerService
}

//显示所有客户信息
func (this *customerView) list() {
	customers := this.customerService.List()
	//显示
	fmt.Println("--------客户列表--------------")
	fmt.Println("编号\t姓名\t性别\t年龄\t电话\t邮箱")
	for i := 0; i < len(customers);i++ {
		//fmt.Println(customers[i].Id,"\t", customers[i].Name...)
		fmt.Println(customers[i].GetInfo())
	}
	fmt.Println("--------客户列表完成-----------")
}

//显示主菜单
func (this *customerView) mainMenu() {
	for {
		fmt.Println("--------客户信息管理软件--------")
		fmt.Println("        1、添加客户")
		fmt.Println("        2、修改客户")
		fmt.Println("        3、删除客户")
		fmt.Println("        4、客户列表")
		fmt.Println("        5、退出")
		fmt.Println()
		fmt.Println("        请选择(1-5):")

		fmt.Scanln(&this.key)

		switch this.key {
		case "1":
			fmt.Println("添加客户")
		case "2":
			fmt.Println("修改客户")
		case "3":
			this.list()
		case "4":
			fmt.Println("客户客户")
		case "5":
			this.loop = false
		default:
			fmt.Println("你的输入有误,请重新输入...")
		}

		if !this.loop {
			break
		}

		fmt.Println("你退出了客户管理系统...")

	}
}

func main() {
	//在 main 函数中,创建一个 customerView,并运行显示主菜单..
	customerView := customerView{
		key:  "",
		loop: true,
	}
	//这里完成对 customerView 结构体的 customerService 字段的初始化
	customerView.customerService = service.NewCustomerService()
	//显示主菜单
	customerView.mainMenu()
}

项目功能实现-添加客户的功能

customerManage/service/customerService.go

customerManage/service/customerView.go

package main

import (
	"fmt"
	"go_code/go_code/chapter13/customerManage/model"
	"go_code/go_code/chapter13/customerManage/service"
)

type customerView struct {
	//定义必要字段
	key  string //接收客户输入...
	loop bool   //表示是否循环的显示主菜单
	//增加一个字段 customerService
	customerService *service.CustomerService
}

//显示所有客户信息
func (this *customerView) list() {
	customers := this.customerService.List()
	//显示
	fmt.Println("--------客户列表--------------")
	fmt.Println("编号\t姓名\t性别\t年龄\t电话\t邮箱")
	for i := 0; i < len(customers);i++ {
		//fmt.Println(customers[i].Id,"\t", customers[i].Name...)
		fmt.Println(customers[i].GetInfo())
	}
	fmt.Println("--------客户列表完成-----------")
}
//得到用户的输入,信息构建新的客户,并完成添加
func (this *customerView) add() {
	fmt.Println("--------添加客户--------------")
	fmt.Println("姓名:")
	name:=""
	fmt.Scanln(&name)
	fmt.Println("性别:")
	gender:=""
	fmt.Scanln(&gender)
	fmt.Println("年龄:")
	age:=0
	fmt.Scanln(&age)
	fmt.Println("电话:")
	phone:=""
	fmt.Scanln(&phone)
	fmt.Println("邮件:")
	email:=""
	fmt.Scanln(&email)
	//构建一个新的 Customer 实例
	//注意: id 号,没有让用户输入,id 是唯一的,需要系统分配
	custmoer:=model.NewCustomer2(name,gender,age,phone,email)
	//调用
	if this.customerService.Add(custmoer){
		fmt.Println("--------添加完成------------")
	}else{
		fmt.Println("--------添加失败------------")
	}
}

//显示主菜单
func (this *customerView) mainMenu() {
	for {
		fmt.Println("--------客户信息管理软件--------")
		fmt.Println("        1、添加客户")
		fmt.Println("        2、修改客户")
		fmt.Println("        3、删除客户")
		fmt.Println("        4、客户列表")
		fmt.Println("        5、退出")
		fmt.Println()
		fmt.Println("        请选择(1-5):")

		fmt.Scanln(&this.key)

		switch this.key {
		case "1":
			fmt.Println("添加客户")
		case "2":
			fmt.Println("修改客户")
		case "3":
			this.list()
		case "4":
			fmt.Println("客户客户")
		case "5":
			this.loop = false
		default:
			fmt.Println("你的输入有误,请重新输入...")
		}

		if !this.loop {
			break
		}

		fmt.Println("你退出了客户管理系统...")

	}
}

func main() {
	//在 main 函数中,创建一个 customerView,并运行显示主菜单..
	customerView := customerView{
		key:  "",
		loop: true,
	}
	//这里完成对 customerView 结构体的 customerService 字段的初始化
	customerView.customerService = service.NewCustomerService()
	//显示主菜单
	customerView.mainMenu()
}

项目功能实现-完成删除客户的功能

customerManage/model/customer.go [没有变化]

customerManage/service/customerService.go

customerManage/view/customerView.go

package main

import (
	"fmt"
	"go_code/go_code/chapter13/customerManage/model"
	"go_code/go_code/chapter13/customerManage/service"
)

type customerView struct {
	//定义必要字段
	key  string //接收客户输入...
	loop bool   //表示是否循环的显示主菜单
	//增加一个字段 customerService
	customerService *service.CustomerService
}

//显示所有客户信息
func (this *customerView) list() {
	customers := this.customerService.List()
	//显示
	fmt.Println("--------客户列表--------------")
	fmt.Println("编号\t姓名\t性别\t年龄\t电话\t邮箱")
	for i := 0; i < len(customers); i++ {
		//fmt.Println(customers[i].Id,"\t", customers[i].Name...)
		fmt.Println(customers[i].GetInfo())
	}
	fmt.Println("--------客户列表完成-----------")
}

//得到用户的输入,信息构建新的客户,并完成添加
func (this *customerView) add() {
	fmt.Println("--------添加客户--------------")
	fmt.Println("姓名:")
	name := ""
	fmt.Scanln(&name)
	fmt.Println("性别:")
	gender := ""
	fmt.Scanln(&gender)
	fmt.Println("年龄:")
	age := 0
	fmt.Scanln(&age)
	fmt.Println("电话:")
	phone := ""
	fmt.Scanln(&phone)
	fmt.Println("邮件:")
	email := ""
	fmt.Scanln(&email)
	//构建一个新的 Customer 实例
	//注意: id 号,没有让用户输入,id 是唯一的,需要系统分配
	custmoer := model.NewCustomer2(name, gender, age, phone, email)
	//调用
	if this.customerService.Add(custmoer) {
		fmt.Println("--------添加完成------------")
	} else {
		fmt.Println("--------添加失败------------")
	}
}
func (this *customerView) delete() {
	flag := false
	fmt.Println("--------删除客户------------")
	for {
		fmt.Println("请选择待删除客户编号(-1)退出:")
		id := -1
		fmt.Scanln(&id)
		if id == -1 {
			return //放弃删除操作
		}
		fmt.Println("确认是否删除(Y/N)")
		//这里同学们可以加入一个循环判断,直到用户输入y或者,才退出
		for {
			choice := ""
			fmt.Scanln(&choice)
			if choice == "y" || choice == "n" {
				if this.customerService.Delete(id) {
					fmt.Println("--------删除完成------------")
					flag = true
				} else {
					fmt.Println("--------删除失败,输入的id号不存在-")
				}
				break
			}
		}
		if flag {
			break
		}
	}
}
func (this *customerView) exit() {
	fmt.Println("确认是否退出(Y/N)")
	for {
		fmt.Scanln(&this.key)
		if this.key == "y" || this.key == "n" {
			break
		} else {
			fmt.Println("输入格式错误,请重新输入!")
		}
	}
	if this.key == "y" {
		this.loop = false
	}
}
func (this *customerView) update() {
	fmt.Println("----------------修改客户------------------")
	fmt.Println("客户id(-1退出):")
	id := -1
	fmt.Scanln(&id)
	if id == -1 {
		return // 放弃修改
	}

	//获取要修改的数据,并显示
	index := this.customerService.FindById(id)
	if index == -1 {
		fmt.Println("------------------客户id不存在------------------")
		return
	}
	fmt.Println("姓名:")
	name := ""
	fmt.Scanln(&name)
	fmt.Println("性别:")
	gender := ""
	fmt.Scanln(&gender)
	fmt.Println("年龄:")
	age := 0
	fmt.Scanln(&age)
	fmt.Println("电话:")
	phone := ""
	fmt.Scanln(&phone)
	fmt.Println("邮箱:")
	email := ""
	fmt.Scanln(&email)

	fmt.Println("你确定要修改吗? y/n")
	choice := ""
	for {
		fmt.Scanln(&choice)
		if choice == "y" || choice == "n" {
			break
		}
		fmt.Println("你输入有误,请重新输入 y/n")
	}

	customer := model.NewCustomer2(name, gender, age, phone, email)

	//调用customerService.Update
	if this.customerService.Update(index, customer) {
		fmt.Println("------------------修改成功------------------")
	} else {
		fmt.Println("------------------修改失败------------------")
	}
}

//显示主菜单
func (this *customerView) mainMenu() {
	for {
		fmt.Println("--------客户信息管理软件--------")
		fmt.Println("        1、添加客户")
		fmt.Println("        2、修改客户")
		fmt.Println("        3、删除客户")
		fmt.Println("        4、客户列表")
		fmt.Println("        5、退出")
		fmt.Println()
		fmt.Println("        请选择(1-5):")

		fmt.Scanln(&this.key)

		switch this.key {
		case "1":
			this.add()
		case "2":
			this.update()
		case "3":
			this.delete()
		case "4":
			this.list()
		case "5":
			this.exit()
		default:
			fmt.Println("你的输入有误,请重新输入...")
		}

		if !this.loop {
			break
		}

		fmt.Println("你退出了客户管理系统...")

	}
}

func main() {
	//在 main 函数中,创建一个 customerView,并运行显示主菜单..
	customerView := customerView{
		key:  "",
		loop: true,
	}
	//这里完成对 customerView 结构体的 customerService 字段的初始化
	customerView.customerService = service.NewCustomerService()
	//显示主菜单
	customerView.mainMenu()
}

项目功能实现-完善退出确认功能(课后作业)

客户关系管理系统-课后练习

CustomerView.go

package main

import (
	"fmt"
	"go_code/go_code/chapter13/customerManage/model"
	"go_code/go_code/chapter13/customerManage/service"
)

type customerView struct {
	//定义必要字段
	key  string //接收客户输入...
	loop bool   //表示是否循环的显示主菜单
	//增加一个字段 customerService
	customerService *service.CustomerService
}

//显示所有客户信息
func (this *customerView) list() {
	customers := this.customerService.List()
	//显示
	fmt.Println("--------客户列表--------------")
	fmt.Println("编号\t姓名\t性别\t年龄\t电话\t邮箱")
	for i := 0; i < len(customers); i++ {
		//fmt.Println(customers[i].Id,"\t", customers[i].Name...)
		fmt.Println(customers[i].GetInfo())
	}
	fmt.Println("--------客户列表完成-----------")
}

//得到用户的输入,信息构建新的客户,并完成添加
func (this *customerView) add() {
	fmt.Println("--------添加客户--------------")
	fmt.Println("姓名:")
	name := ""
	fmt.Scanln(&name)
	fmt.Println("性别:")
	gender := ""
	fmt.Scanln(&gender)
	fmt.Println("年龄:")
	age := 0
	fmt.Scanln(&age)
	fmt.Println("电话:")
	phone := ""
	fmt.Scanln(&phone)
	fmt.Println("邮件:")
	email := ""
	fmt.Scanln(&email)
	//构建一个新的 Customer 实例
	//注意: id 号,没有让用户输入,id 是唯一的,需要系统分配
	custmoer := model.NewCustomer2(name, gender, age, phone, email)
	//调用
	if this.customerService.Add(custmoer) {
		fmt.Println("--------添加完成------------")
	} else {
		fmt.Println("--------添加失败------------")
	}
}
func (this *customerView) delete() {
	flag := false
	fmt.Println("--------删除客户------------")
	for {
		fmt.Println("请选择待删除客户编号(-1)退出:")
		id := -1
		fmt.Scanln(&id)
		if id == -1 {
			return //放弃删除操作
		}
		fmt.Println("确认是否删除(Y/N)")
		//这里同学们可以加入一个循环判断,直到用户输入y或者,才退出
		for {
			choice := ""
			fmt.Scanln(&choice)
			if choice == "y" || choice == "n" {
				if this.customerService.Delete(id) {
					fmt.Println("--------删除完成------------")
					flag = true
				} else {
					fmt.Println("--------删除失败,输入的id号不存在-")
				}
				break
			}
		}
		if flag {
			break
		}
	}
}
func (this *customerView) exit() {
	fmt.Println("确认是否退出(Y/N)")
	for {
		fmt.Scanln(&this.key)
		if this.key == "y" || this.key == "n" {
			break
		} else {
			fmt.Println("输入格式错误,请重新输入!")
		}
	}
	if this.key == "y" {
		this.loop = false
	}
}
func (this *customerView) update() {
	fmt.Println("----------------修改客户------------------")
	fmt.Println("客户id(-1退出):")
	id := -1
	fmt.Scanln(&id)
	if id == -1 {
		return // 放弃修改
	}

	//获取要修改的数据,并显示
	index := this.customerService.FindById(id)
	if index == -1 {
		fmt.Println("------------------客户id不存在------------------")
		return
	}
	fmt.Println("姓名:")
	name := ""
	fmt.Scanln(&name)
	fmt.Println("性别:")
	gender := ""
	fmt.Scanln(&gender)
	fmt.Println("年龄:")
	age := 0
	fmt.Scanln(&age)
	fmt.Println("电话:")
	phone := ""
	fmt.Scanln(&phone)
	fmt.Println("邮箱:")
	email := ""
	fmt.Scanln(&email)

	fmt.Println("你确定要修改吗? y/n")
	choice := ""
	for {
		fmt.Scanln(&choice)
		if choice == "y" || choice == "n" {
			break
		}
		fmt.Println("你输入有误,请重新输入 y/n")
	}

	customer := model.NewCustomer2(name, gender, age, phone, email)

	//调用customerService.Update
	if this.customerService.Update(index, customer) {
		fmt.Println("------------------修改成功------------------")
	} else {
		fmt.Println("------------------修改失败------------------")
	}
}

//显示主菜单
func (this *customerView) mainMenu() {
	for {
		fmt.Println("--------客户信息管理软件--------")
		fmt.Println("        1、添加客户")
		fmt.Println("        2、修改客户")
		fmt.Println("        3、删除客户")
		fmt.Println("        4、客户列表")
		fmt.Println("        5、退出")
		fmt.Println()
		fmt.Println("        请选择(1-5):")

		fmt.Scanln(&this.key)

		switch this.key {
		case "1":
			this.add()
		case "2":
			this.update()
		case "3":
			this.delete()
		case "4":
			this.list()
		case "5":
			this.exit()
		default:
			fmt.Println("你的输入有误,请重新输入...")
		}

		if !this.loop {
			break
		}

		fmt.Println("你退出了客户管理系统...")

	}
}

func main() {
	//在 main 函数中,创建一个 customerView,并运行显示主菜单..
	customerView := customerView{
		key:  "",
		loop: true,
	}
	//这里完成对 customerView 结构体的 customerService 字段的初始化
	customerView.customerService = service.NewCustomerService()
	//显示主菜单
	customerView.mainMenu()
}

CustomerService.go

package service

import (
	"go_code/go_code/chapter13/customerManage/model"
)

type CustomerService struct {
	customers []model.Customer
	//声明一个字段,表示当前切片含有多少个客户
	//该字段后面,还可以作为新客户的 id+1
	customerNum int
}

//编写一个方法,可以返回*CustmoerService
func NewCustomerService() *CustomerService {
	//为了能够看到有客户在切片中,我们初始化一个切片
	custmoerService := &CustomerService{}
	custmoerService.customerNum = 1
	custmoer := model.NewCustomer(1, "张三", "男",
		20, "112", "zhangsan@sohu.com")
	custmoerService.customers = append(custmoerService.customers, custmoer)
	return custmoerService
}

//返回客户切片
func (this *CustomerService) List() []model.Customer {
	return this.customers
}

//添加客户到切片
//!!!
func (this *CustomerService) Add(custmoer model.Customer) bool {
	this.customerNum++
	custmoer.Id = this.customerNum
	this.customers = append(this.customers, custmoer)
	return true
}
func (this *CustomerService) Delete(id int) bool {
	index := this.FindById(id)
	//如果index==-1,说明没有这个客户
	if index ==-1{
		return false
	}
	//如何从切片中删除一个元素
	this.customers=append(this.customers[:index],this.customers[index+1:]...)
	return true
}

func (this *CustomerService)Update(index int,customer model.Customer)bool{
	this.customers[index].Name= customer.Name
	this.customers[index].Age= customer.Age
	this.customers[index].Gender= customer.Gender
	this.customers[index].Phone= customer.Phone
	this.customers[index].Email= customer.Email
	return true
}
//根据id查找客户在切片中对应的下表,如果没有该客户,返回-1
func (this *CustomerService) FindById(id int) int {
	index := -1
	for i := 0; i < len(this.customers); i++ {
		if this.customers[i].Id == id {
			index = i
		}
	}
	return index
}

到此这篇关于Go-客户信息关系系统的实现的文章就介绍到这了,更多相关Go-客户信息关系系统内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • Golang 获取系统信息的实现

    目录 问题提出 golang 的编译选项 获取系统信息 本文介绍获取系统信息的方法,另外给出根据不同系统编译的方法. 问题提出 由于多年来接触了不同系统的兼容工程,对使用宏区分不同的代码一直有一种莫名的感觉.像 Linux 内核中就有很多这样的代码,coreboot 中有,nRF52 SDK中也有.在实现的工程库也要往这方向考虑,比如线程库和socket库.当接触 golang 后,因其跨平台,编码快,所以在工作中也使用了.但并不是所有代码都是跨平台,像 syscall这样的包,就无法做到.最近

  • go-cqhttp权限管理系统的实现代码

    目录 权限管理系统 一. 概述 二. 创建表 1. 创建 2. 生成 3. 映射 三. 增删改查 1. 群管理 1.1 增加群 1.2 删除群 1.3 展示功能 2. 权限管理 2.1 展示权限 2.2 修改权限 四. 获取命令 1. 消息分发 2. 解析命令 权限管理系统 一. 概述 在写好我们的智能聊天功能之后,大家有没有感觉很烦呢?感觉这个机器人在群里面一直被艾特,一直被戳一戳.那么,我们有没有一种方法,使得其在群里面的权限可控呢? 或许大家看到这个问题就想到了一个方法,那就是通过pyth

  • Go语言实战之实现一个简单分布式系统

    目录 引子 思路 实战 节点通信 主节点 工作节点 将它们放在一起 代码效果 总结 引子 如今很多云原生系统.分布式系统,例如 Kubernetes,都是用 Go 语言写的,这是因为 Go 语言天然支持异步编程,而且静态语言能保证应用系统的稳定性.笔者的开源项目 Crawlab 作为爬虫管理平台,也应用到了分布式系统.本篇文章将介绍如何用 Go 语言编写一个简单的分布式系统. 思路 在开始写代码之前,我们先思考一下需要实现些什么. 主节点(Master Node):中控系统,相当于军队中的指挥官

  • GoLang日志监控系统实现

    目录 日志监控系统 项目简答介绍 系统架构 读取模块具体实现 日志解析模块 日志监控系统 Nginx(日志文件) -> log_process (实时读取解析写入) -> influxdb(存储) ->grafana(前端日志展示器) influxdb 属于GO语言编写的开源的时序型数据,着力于高性能 查询与存储时序型数据,influxdb 广泛的应用于存储系统的监控数据,IOT行业的实时数据. 目前市面上流行 TSDB(时序型处理数据库):influxDB, TimescaleDB,

  • Django超详细讲解图书管理系统的实现

    目录 1.用户管理模块 2.图书管理模块 3.数据管理模块 4.前端模块 项目使用python开发,采用Django框架,数据库采用MySQL,根据用户人员的不同分成两套系统,分别是学生系统和管理员系统,功能模块具体分成四个,分别是用户管理模块.图书管理模块.数据管理模块.前端模块. 1.用户管理模块 用户管理模块实现的功能包括用户注册(分为学生注册和管理员注册).用户信息修改.用户登录和判定 用户注册和登录 views.py中用户注册及登陆判定代码段 def login(request):#登

  • Go开源项目分布式唯一ID生成系统

    目录 前言 项目背景 项目使用 HTTP 方式 gRPC 方式 本地开发 项目架构 前言 今天跟大家介绍一个开源项目:id-maker,主要功能是用来在分布式环境下生成唯一 ID.上周停更了一周,也是用来开发和测试这个项目的相关代码. 美团有一个开源项目叫 Leaf,使用 Java 开发.本项目就是在此思路的基础上,使用 Go 开发实现的. 项目整体代码量并不多,不管是想要在实际生产环境中使用,还是想找个项目练手,我觉得都是一个不错的选择. 项目背景 在大部分系统中,全局唯一 ID 都是一个强需

  • JSP实现客户信息管理系统

    本文实例为大家分享了JSP实现客户信息管理系统的具体代码,供大家参考,具体内容如下 项目示意图大概这样吧.我自己画的 登录界面代码 index.jsp: 完全没技术含量的,直接调用一个servlet控制的是否登录 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD

  • java实现客户信息管理系统

    本文实例为大家分享了java实现客户信息管理系统的具体代码,供大家参考,具体内容如下 一.CMUtility工具类 讲不同的功能封装为方法,就是可以直接通过调用方法使用它的功能,而无需考虑具体的功能实现细节. 代码如下: package com.p2.util; import java.util.*; /** * 工具类 * 讲不同的功能封装为方法,就是可以直接通过调用方法使用它的功能,而无需考虑具体的功 * 能实现细节. * **/ public class CMUtility { priva

  • 利用java实现一个客户信息管理系统

    用博客记录我自学的点点滴滴 类图: Customer类: public class Customer { /** * @name 客户姓名 * @sex 性别 * @age 年龄 * @phone 电话号码 * @email 邮箱 */ private String name; private String sex; private int age; private String phone; private String email; public Customer(){}; public C

  • Java实战之客户信息管理系统

    一.软件设计结构 对于初学者来说,弄清框架显得尤为重要 首先该软件有以下三种模块组成 二.MVC设计模式 模型层:Customer处理数据 控制层:CustomerList处理业务逻辑 视图层:CustomerView显示数据 以下三点建议结合代码理解 1.Customer为实体对象,用于封装客户信息 2.CustomerList为Customer对象的管理模块,内部用数组管理一组Customer对象,并提供相应的添加.修改.删除和遍历的方法,供CustomerView调用 3.Customer

  • 详解Java如何使用集合来实现一个客户信息管理系统

    目录 1 客户类 2 主界面 3 方法 (1)添加客户 (2)判断编号是否被占用 (3)修改客户信息 (4)删除客户 (5)客户列表 (6)退出 4 问题总结 (1)字符串比较问题 (2)修改客户不成功 (3)get和set方法使用时的疑惑 (为什么这里用set那里用get?) 1 客户类 public class Customers { private String cid; private String name; private String sex; private String age

  • Java实现简单客户信息管理系统

    本文实例为大家分享了Java实现客户信息管理系统的具体代码,供大家参考,具体内容如下 一.目标 模拟实现一个基于文本界面的<客户信息管理软件> 进一步掌握编程技巧和调试技巧,熟悉面向对象编程 主要涉及以下知识点: 类结构的使用:属性.方法及构造器 对象的创建与使用 类的封装性 声明和使用数组 数组的插入.删除和替换 关键字的使用:this 二.系统结构设计 CustomerView为主模块,负责菜单的显示和处理用户操作 CustomerList为Customer对象的管理模块,内部用数组管理一

  • java实现简单的客户信息管理系统

    本文实例为大家分享了java实现简单客户信息管理系统的具体代码,供大家参考,具体内容如下 全篇文章开源,源码供读者使用.这是一篇关于java的客户信息管理系统的文章,里面简单实现了数据库管理系统的基本功能,可以算是算笔者的学习笔记,也为大家学习提供便利.所以代码都是在一个包下完成的,所以没有使用导包的操作,省去了外卖project的申明,剩下的就写的文章里了.话不多说,看文章吧.首先给大家看一下总的操作界面(别看简单,里面的还是有东西的),后面就附上实现源码.要求和注释 Customer类 下面

  • JS基于cookie实现来宾统计记录访客信息的方法

    本文实例讲述了JS基于cookie实现来宾统计记录访客信息的方法.分享给大家供大家参考.具体如下: 这里使用JavaScript记录访客的来宾信息,记录是第几次来访,显示的信息有:您的名字;您浏览该网页的次数;您上次浏览网页的时间.可以更改姓名. 运行效果如下图所示: 具体代码如下: <html> <head> <title>记录客户信息</title> <script language="JavaScript"> <!

  • HTTP头信息总结

    本文为多篇"HTTP请求头相关文章"及<HTTP权威指南>一书的阅读后个人汇总整理版,以便于理解. 通常HTTP消息包括客户机向服务器的请求消息和服务器向客户机的响应消息.客户端向服务器发送一个请求,请求头包含请求的方法.URI.协议版本.以及包含请求修饰符.客户信息和内容的类似于MIME的消息结构.服务器以一个状态行作为响应,相应的内容包括消息协议的版本,成功或者错误编码加上包含服务器信息.实体元信息以及可能的实体内容. Http协议定义了很多与服务器交互的方法,最基本的

  • 基于Cookie使用过滤器实现客户每次访问只登录一次

    相信大家在各大网站都会遇到,登录时,在登录框出现下次免登陆/一个月免登陆的类似选项,本文就是讲解如何实现,在这记录一下,也算是做个备忘录合集,如果文中有错,欢迎大家指出 为啥说自登陆一次呢,因为当访问某个页面时,如果第一次自动登录失败时,你下次刷新访问时还再次走自动登录流程,就会出现死循环. 本文代码示例框架为Spring MVC,下面就讲解实现该功能的需要掌握哪些知识:cookies与过滤器 1.cookies 何为Cookies:Cookies为 Web 应用程序保存用户相关信息提供了一种有

随机推荐