亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

java實(shí)現(xiàn)簡(jiǎn)單的客戶信息管理系統(tǒng)

 更新時(shí)間:2022年06月06日 11:22:15   作者:原創(chuàng)小白變怪獸  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)簡(jiǎn)單的客戶信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java實(shí)現(xiàn)簡(jiǎn)單客戶信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

全篇文章開(kāi)源,源碼供讀者使用。這是一篇關(guān)于java的客戶信息管理系統(tǒng)的文章,里面簡(jiǎn)單實(shí)現(xiàn)了數(shù)據(jù)庫(kù)管理系統(tǒng)的基本功能,可以算是算筆者的學(xué)習(xí)筆記,也為大家學(xué)習(xí)提供便利。所以代碼都是在一個(gè)包下完成的,所以沒(méi)有使用導(dǎo)包的操作,省去了外賣project的申明,剩下的就寫的文章里了。話不多說(shuō),看文章吧。
首先給大家看一下總的操作界面(別看簡(jiǎn)單,里面的還是有東西的),后面就附上實(shí)現(xiàn)源碼、要求和注釋

Customer類

下面是關(guān)于Customer類的編寫要求:

* 用來(lái)封裝客戶的以下信息
* Sting name
* int age
* char gender
* Stirng phone
* String email
* 提供getset方法
* 構(gòu)造器自行設(shè)定

public class Customer {
?? ?private String name;
?? ?private int age;
?? ?private String gender;
?? ?private String phone;
?? ?private String email;
?? ?
?? ?public Customer() {
?? ??? ?
?? ?}
?? ?
?? ?public Customer(String name,int age,String gender,String phone,String email) {
?? ??? ?this.name = name;
?? ??? ?this.age = age;
?? ??? ?this.gender = gender;
?? ??? ?this.phone = phone;
?? ??? ?this.email = email;
?? ?}
?? ?
?? ?public String getName() {
?? ??? ?return name;
?? ?}
?? ?public void setName(String name) {
?? ??? ?this.name = name;
?? ?}
?? ?public int getAge() {
?? ??? ?return age;
?? ?}
?? ?public void setAge(int age) {
?? ??? ?this.age = age;
?? ?}
?? ?public String getGender() {
?? ??? ?return gender;
?? ?}
?? ?public void setGender(String gender) {
?? ??? ?this.gender = gender;
?? ?}
?? ?public String getPhone() {
?? ??? ?return phone;
?? ?}
?? ?public void setPhone(String phone) {
?? ??? ?this.phone = phone;
?? ?}
?? ?public String getEmail() {
?? ??? ?return email;
?? ?}
?? ?public void setEmail(String email) {
?? ??? ?this.email = email;
?? ?}
?? ?
}

CustomerList類

下面是關(guān)于CustomerList類的編寫要求:

* CustomerList類的設(shè)計(jì)
* Customer[] 用來(lái)保存客戶信息
* int total 用來(lái)保存當(dāng)前存入客戶數(shù)量
* 該類至少提供以下的構(gòu)造器和方法
* public CustomerLIst(int totalCustomer);
* public boolean addCustomer(Customer customer);
* public boolean replaceCustomer(int index,Customer cust);
* public boolean deleteCustomer(int index);
* public Customer[] getallCustomer();
* public Customer getCustomer(int index);
* public int getToal();

public class CustomerList {
?? ?private static Customer customers[];
?? ?private static int total;
?? ?
?? ?public CustomerList(int totalCustomer) {
?? ??? ?customers = new Customer[totalCustomer];
?? ?}
?? ?
?? ?// 添加客戶
?? ?public boolean addCustomer(Customer customer) {
?? ??? ?if(total >= customers.length) {
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?customers[total++] = customer;
?? ??? ?return true;
?? ?}
?? ?
?? ?// 修改指定位置的客戶信息
?? ?public boolean replaceCustomer(int index,Customer cust) {
?? ??? ?if(index < 0 || index >= total) {
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?customers[index] = cust;
?? ??? ?return true;
?? ?}
?? ?
?? ?// 刪除指定位置的客戶
?? ?public boolean deleteCustomer(int index) {
?? ??? ?if(index < 0 || index >= total) {
?? ??? ??? ?return false;
?? ??? ?}
?? ??? ?for(int i = index;i < total - 1;i++) {
?? ??? ??? ?customers[i] = customers[i+1];
?? ??? ?}
?? ??? ?customers[total - 1] = null;
?? ??? ?total--;
?? ??? ?return true;
?? ?}
?? ?
?? ?// 得到所有客戶的信息
?? ?public static Customer[] getallCustomer() {
?? ??? ?Customer[] custs = new Customer[total];
?? ??? ?for(int i = 0;i < total;i++) {
?? ??? ??? ?custs[i] = customers[i];
?? ??? ?}
?? ??? ?return custs;
?? ?}
?? ?
?? ?// 得到指定客戶的信息
?? ?public Customer getCustomer(int index) {
?? ??? ?if(index < 0 || index >= total) {
?? ??? ??? ?return null;
?? ??? ?}
?? ??? ?return customers[index];
?? ?}
?? ?
?? ?// 得到Customers中所有客戶的個(gè)數(shù)
?? ?public static int getTotal() {
?? ??? ?return total;
?? ?}
?? ?
}

CustomerView類

CustomerView類的編寫

* 主模塊:用于用戶界面的展示、與用戶交互
* CustomerList  customerList = new CustomerList(10) 
* 應(yīng)含有的構(gòu)造器和方法
* private void enterMainMenue()
* private void addNewCustomer()
* private void modifyCustomer()
* private void deleteCustomer()
* private void listAllCustomers()
* private static void main(String[] args)

public class CustomerView {

?? ?CustomerList customerList = new CustomerList(10);

?? ?public CustomerView() {
?? ??? ?Customer customer = new Customer("王龍", 20, "Male", "18965391649", "465989777@qq.com");
?? ??? ?customerList.addCustomer(customer);
?? ?}

?? ?// 用戶主菜單
?? ?private void enterMainMenue() {
?? ??? ?System.out.println("-----------------客戶信息管理系統(tǒng) --------------------");
?? ??? ?System.out.println("?? ??? ??? ??? ??? ?1-添加客戶");
?? ??? ?System.out.println("?? ??? ??? ??? ??? ?2-修改客戶");
?? ??? ?System.out.println("?? ??? ??? ??? ??? ?3-刪除客戶");
?? ??? ?System.out.println("?? ??? ??? ??? ??? ?4-客戶列表");
?? ??? ?System.out.println("?? ??? ??? ??? ??? ?5-退出");
?? ??? ?System.out.println("請(qǐng)選擇1-5:");
?? ?}

?? ?// 添加客戶
?? ?private void addNewCustomer() {
?? ??? ?// System.out.println("添加客戶的操作");
?? ??? ?System.out.println("-----------------添加客戶-------------------------");
?? ??? ?Scanner in = new Scanner(System.in);
?? ??? ?System.out.print("姓名:");
?? ??? ?String name = in.nextLine();
?? ??? ?System.out.print("年齡:");
?? ??? ?int age = in.nextInt();
?? ??? ?System.out.print("性別:");
?? ??? ?String gender = in.nextLine();
?? ??? ?System.out.print("電話:");
?? ??? ?String phone = in.nextLine();
?? ??? ?System.out.print("郵箱:");
?? ??? ?String email = in.nextLine();

?? ??? ?// 將上述數(shù)據(jù)封裝到Customer中
?? ??? ?Customer customer = new Customer(name, age, gender, phone, email);
?? ??? ?boolean isSuccess = customerList.addCustomer(customer);
?? ??? ?if (isSuccess == true) {
?? ??? ??? ?System.out.println("---------------添加完成---------------------");
?? ??? ?} else {
?? ??? ??? ?System.out.println("---------------客戶目錄已滿,添加失??!---------------------");
?? ??? ?}
?? ?}

?? ?// 修改客戶
?? ?private void modifyCustomer() {
?? ??? ?// System.out.println("修改客戶的操作");
?? ??? ?Scanner in = new Scanner(System.in);
?? ??? ?Customer cust;
?? ??? ?int num;
?? ??? ?System.out.print("請(qǐng)選擇待修改客戶的編號(hào)(-1退出):");
?? ??? ?while (true) {
?? ??? ??? ?num = in.nextInt();
?? ??? ??? ?if (num == -1) {
?? ??? ??? ??? ?return;
?? ??? ??? ?}
?? ??? ??? ?cust = customerList.getCustomer(num - 1);
?? ??? ??? ?if (cust == null) {
?? ??? ??? ??? ?System.out.print("無(wú)法找到指定客戶,請(qǐng)選擇待修改客戶的編號(hào)(-1退出):");
?? ??? ??? ?} else {
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}

?? ??? ?// 開(kāi)始修改客戶信息
?? ??? ?System.out.print("姓名(" + cust.getName() + "):");
?? ??? ?String name = in.nextLine();
?? ??? ?System.out.print("性別(" + cust.getGender() + "):");
?? ??? ?String gender = in.nextLine();
?? ??? ?System.out.print("年齡(" + cust.getAge() + "):");
?? ??? ?int age = in.nextInt();
?? ??? ?System.out.print("電話(" + cust.getPhone() + "):");
?? ??? ?String phone = in.nextLine();
?? ??? ?System.out.print("郵箱(" + cust.getEmail() + "):");
?? ??? ?String email = in.nextLine();

?? ??? ?Customer cust2 = new Customer(name, age, gender, phone, email);
?? ??? ?boolean isreplace = customerList.replaceCustomer(num - 1, cust2);
?? ??? ?if (isreplace == true) {
?? ??? ??? ?System.out.println("---------------修改完成---------------------");
?? ??? ?} else {
?? ??? ??? ?System.out.println("---------------修改失敗---------------------");
?? ??? ?}
?? ?}

?? ?// 刪除用戶
?? ?private void deleteCustomer() {
?? ??? ?// System.out.println("刪除客戶的操作");
?? ??? ?Scanner in = new Scanner(System.in);
?? ??? ?int num;
?? ??? ?System.out.println("------------------刪除客戶-----------------------");
?? ??? ?while (true) {
?? ??? ??? ?System.out.println("輸入要?jiǎng)h除的客戶的序號(hào)(-1退出):");
?? ??? ??? ?num = in.nextInt();
?? ??? ??? ?if (num == -1) {
?? ??? ??? ??? ?return;
?? ??? ??? ?}
?? ??? ??? ?Customer customer = customerList.getCustomer(num - 1);
?? ??? ??? ?if (customer == null) {
?? ??? ??? ??? ?System.out.println("------------------刪除失?。?----------------------");
?? ??? ??? ??? ?return;
?? ??? ??? ?}

?? ??? ??? ?// 執(zhí)行刪除操作
?? ??? ??? ?System.out.print("是否確認(rèn)刪除(y/n):");
?? ??? ??? ?char isdelete = in.nextLine().charAt(0);
?? ??? ??? ?if (isdelete == 'y') {
?? ??? ??? ??? ?boolean is = customerList.deleteCustomer(num - 1);
?? ??? ??? ??? ?if(is) {
?? ??? ??? ??? ??? ?System.out.println("------------------刪除成功-----------------------");?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}else {
?? ??? ??? ??? ??? ?System.out.println("------------------刪除失敗-----------------------");?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}
?? ??? ??? ?}else {
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ?}

?? ?// 列出所有客戶信息
?? ?private void listAllCustomers() {
?? ??? ?System.out.println("---------------客戶列表--------------------");
?? ??? ?int total = CustomerList.getTotal();
?? ??? ?if (total == 0) {
?? ??? ??? ?System.out.println("沒(méi)有客戶記錄!");
?? ??? ?} else {
?? ??? ??? ?System.out.println("編號(hào)\t姓名\t性別\t電話\t\t郵箱\t");
?? ??? ??? ?Customer custs[] = CustomerList.getallCustomer();
?? ??? ??? ?for (int i = 0; i < custs.length; i++) {
?? ??? ??? ??? ?Customer cust = custs[i];
?? ??? ??? ??? ?System.out.println((i + 1) + "\t" + cust.getName() + "\t" + cust.getGender() + "\t" + cust.getPhone()
?? ??? ??? ??? ??? ??? ?+ "\t" + cust.getEmail());
?? ??? ??? ?}
?? ??? ?}

?? ??? ?System.out.println("---------------客戶列表加載完成--------------------");
?? ?}

?? ?// 主函數(shù)
?? ?public static void main(String[] args) {
?? ??? ?CustomerView view = new CustomerView();
?? ??? ?Scanner in = new Scanner(System.in);

?? ??? ?boolean isFlag = true;
?? ??? ?while (isFlag) {
?? ??? ??? ?view.enterMainMenue();
?? ??? ??? ?char menu = in.nextLine().charAt(0);
?? ??? ??? ?switch (menu) {
?? ??? ??? ?case '1':
?? ??? ??? ??? ?view.addNewCustomer();
?? ??? ??? ??? ?break;
?? ??? ??? ?case '2':
?? ??? ??? ??? ?view.modifyCustomer();
?? ??? ??? ??? ?break;
?? ??? ??? ?case '3':
?? ??? ??? ??? ?view.deleteCustomer();
?? ??? ??? ??? ?break;
?? ??? ??? ?case '4':
?? ??? ??? ??? ?view.listAllCustomers();
?? ??? ??? ??? ?break;
?? ??? ??? ?case '5':
?? ??? ??? ??? ?System.out.print("確認(rèn)是否退出(y/n):");
?? ??? ??? ??? ?char flag = in.nextLine().charAt(0);
?? ??? ??? ??? ?if (flag == 'y') {
?? ??? ??? ??? ??? ?isFlag = false;
?? ??? ??? ??? ?}
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ??? ?// isFlag = false;
?? ??? ?}
?? ??? ?in.close();
?? ?}
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • JAVA SFTP文件上傳、下載及批量下載實(shí)例

    JAVA SFTP文件上傳、下載及批量下載實(shí)例

    本篇文章主要介紹了JAVA SFTP文件上傳、下載及批量下載實(shí)例,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-03-03
  • java8新特性教程之time包使用總結(jié)

    java8新特性教程之time包使用總結(jié)

    Java8新增了date和time的util包,下面這篇文章主要給大家介紹了關(guān)于java8新特性教程之time包使用的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-01-01
  • SpringBoot實(shí)現(xiàn)異步任務(wù)的項(xiàng)目實(shí)踐

    SpringBoot實(shí)現(xiàn)異步任務(wù)的項(xiàng)目實(shí)踐

    本文將使用SpringBoot 去實(shí)現(xiàn)異步之間的調(diào)用,提高系統(tǒng)的并發(fā)性能、用戶體驗(yàn),具有一定的參考價(jià)值,感興趣的可以了解一下
    2023-10-10
  • 詳解Springboot分布式限流實(shí)踐

    詳解Springboot分布式限流實(shí)踐

    這篇文章主要介紹了詳解Springboot分布式限流實(shí)踐 ,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-06-06
  • Java批量導(dǎo)出word壓縮后的zip文件案例

    Java批量導(dǎo)出word壓縮后的zip文件案例

    這篇文章主要介紹了Java批量導(dǎo)出word壓縮后的zip文件案例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-10-10
  • Java Calendar類使用總結(jié)及使用實(shí)例

    Java Calendar類使用總結(jié)及使用實(shí)例

    這篇文章主要介紹了Java Calendar類使用總結(jié)及使用實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2019-03-03
  • springcloud中Ribbon和RestTemplate實(shí)現(xiàn)服務(wù)調(diào)用與負(fù)載均衡

    springcloud中Ribbon和RestTemplate實(shí)現(xiàn)服務(wù)調(diào)用與負(fù)載均衡

    這篇文章主要介紹了Ribbon和RestTemplate實(shí)現(xiàn)服務(wù)調(diào)用與負(fù)載均衡,想了解負(fù)載均衡的同學(xué)可以參考下
    2021-04-04
  • MybatisPlus調(diào)用原生SQL的實(shí)現(xiàn)方法

    MybatisPlus調(diào)用原生SQL的實(shí)現(xiàn)方法

    本文主要介紹了MybatisPlus調(diào)用原生SQL的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2023-02-02
  • Servlet實(shí)現(xiàn)代理文件下載功能

    Servlet實(shí)現(xiàn)代理文件下載功能

    這篇文章主要為大家詳細(xì)介紹了Servlet實(shí)現(xiàn)代理文件下載功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Java Stream 流的使用過(guò)程解析

    Java Stream 流的使用過(guò)程解析

    這篇文章主要介紹了Java Stream 流的使用過(guò)程解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-10-10

最新評(píng)論