资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

客户入住登记java代码 客户入住登记java代码是什么

用JAVA编写购物系统的代码是什么?(急)

算是最简单的吧

伊金霍洛网站建设公司成都创新互联,伊金霍洛网站设计制作,有大型网站制作公司丰富经验。已为伊金霍洛千余家提供企业网站建设服务。企业网站搭建\成都外贸网站制作要多少钱,请找那个售后服务好的伊金霍洛做网站的公司定做!

package cn.job01;

import java.util.Scanner;

public class Lx07 {

public static void choice() {

System.out.println("登陆菜单 ");

System.out.println("1登陆系统");

System.out.println("2退出");

}

static void choice1() {

System.out.println("购物管理系统客户信息");

System.out.println("1显示所有客户信息");

System.out.println("2添加客户信息");

System.out.println("3修改客户信息");

System.out.println("4查询客户信息");

}

static void choice2() {

System.out.println("购物管理系统真情回馈");

System.out.println("1幸运大放送");

System.out.println("2幸运抽奖");

System.out.println("3生日问候");

}

public static void main(String[] args) {

choice();

Scanner input = new Scanner(System.in);

System.out.println("请输入1or2");

int num = input.nextInt();

switch (num) {

case 1:

System.out.println("主菜单");

System.out.println("1客户信息管理");

System.out.println("2购物结算");

System.out.println("3真情回馈");

System.out.println("4注销");

break;

}

System.out.println("选择输入数字");

int num1 = input.nextInt();

switch (num1) {

case 1:

choice1();

break;

case 2:

System.out.println("购物结算");

break;

case 3:

choice2();

break;

case 4:

choice();

break;

}

}

}

编程Customer.java:编写Customer类,编程Account.java:编写Account 类,使用上面的两个类,实现如下业务

Customer类:

package Test;

public class Customer {

private String customerId;//客户身份证号

private String custName;//客户姓名

private String custGender;//客户性别

public Customer(String customerId,String custName,String custGender){

this.custGender=custGender;

this.custName= custName;

this.customerId= customerId;

}

public String getCustomerId() {

return customerId;

}

public void setCustomerId(String customerId) {

this.customerId = customerId;

}

public String getCustName() {

return custName;

}

public void setCustName(String custName) {

this.custName = custName;

}

public String getCustGender() {

return custGender;

}

public void setCustGender(String custGender) {

this.custGender = custGender;

}

public void printMSG(){

System.out.println("身份证号:"+this.customerId+"姓名:"+this.custName+"性别:"+this.custGender);

}

}

Account类:

package Test;

public class Account {

private String customerId;//该账户所属客户的身份证号

private String accountNo;//账户号

private float balance;//余额

public Account(String customerId,String accountNo,float balance){

this.customerId= customerId;

this.accountNo = accountNo;

this.balance = balance;

}

public Account(String customerId,String accountNo){

this(customerId,accountNo,0);

}

public float deposit(float amount) {

System.out.println("本次存款:"+amount);

balance= balance+amount;

return amount;

}

public float withdraw (float amount){

System.out.println("本次取款:"+amount);

balance= balance-amount;

if(balance=0){

return amount;

}else{

return 0;

}

}

public float getBalance(){

return balance;

}

}

Ex4_3类:

package Test;

public class Ex4_3 {

public static void main(String [] args){

//创建两个客户“张三”、“李四”;为张三开设2个账户

//(一个账户开户时就存款2000,另一账户开户时不存款)、

//李四开设1个账户(开户时存款3000)。

Customer customer1 = new Customer("111","张三","男");

Customer customer2 = new Customer("222","李四","女");

Account account1 = new Account(customer1.getCustomerId(),"zhangsan1",2000);

Account account2 = new Account(customer1.getCustomerId(),"zhangsan2");

Account account3 = new Account(customer2.getCustomerId(),"lisi",3000);

System.out.println("张三第一个账户取款500:");

account1.withdraw(500);

System.out.println("张三从第一个账户转账1000到第二个账户中:");

account2.deposit(account1.withdraw(1000));

System.out.println("李四取款300:");

account3.withdraw(300);

System.out.println("最后查询出张三与李四的客户信息及账户余额:");

customer1.printMSG();

System.out.println("账户1余额:"+account1.getBalance()+"账户2余额:"+account2.getBalance());

customer2.printMSG();

System.out.println("李四账户1余额"+account3.getBalance());

}

}

登陆界面的java代码怎么写?

概述

具体框架使用jframe,文本框组件:JTextField;密码框组件:JPasswordField;标签组件:JLabel;复选框组件:JCheckBox;单选框组件:JRadioButton;按钮组件JButton。

登录界面:

代码实例

import javax.swing.*;

import java.awt.*;   //导入必要的包

public class denglu extends JFrame{

JTextField jTextField ;//定义文本框组件

JPasswordField jPasswordField;//定义密码框组件

JLabel jLabel1,jLabel2;

JPanel jp1,jp2,jp3;

JButton jb1,jb2; //创建按钮

public denglu(){

jTextField = new JTextField(12);

jPasswordField = new JPasswordField(13);

jLabel1 = new JLabel("用户名");

jLabel2 = new JLabel("密码");

jb1 = new JButton("确认");

jb2 = new JButton("取消");

jp1 = new JPanel();

jp2 = new JPanel();

jp3 = new JPanel();

//设置布局

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

jp1.add(jLabel1);

jp1.add(jTextField);//第一块面板添加用户名和文本框

jp2.add(jLabel2);

jp2.add(jPasswordField);//第二块面板添加密码和密码输入框

jp3.add(jb1);

jp3.add(jb2); //第三块面板添加确认和取消

//        jp3.setLayout(new FlowLayout());  //因为JPanel默认布局方式为FlowLayout,所以可以注销这段代码.

this.add(jp1);

this.add(jp2);

this.add(jp3);  //将三块面板添加到登陆框上面

//设置显示

this.setSize(300, 200);

//this.pack();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

this.setVisible(true);

this.setTitle("登陆");

}

public static void main(String[] args){

new denglu();

}

}

拓展内容

java swing包

Swing 是一个为Java设计的GUI工具包。

Swing是JAVA基础类的一部分。

Swing包括了图形用户界面(GUI)器件如:文本框,按钮,分隔窗格和表。

Swing提供许多比AWT更好的屏幕显示元素。它们用纯Java写成,所以同Java本身一样可以跨平台运行,这一点不像AWT。它们是JFC的一部分。它们支持可更换的面板和主题(各种操作系统默认的特有主题),然而不是真的使用原生平台提供的设备,而是仅仅在表面上模仿它们。这意味着你可以在任意平台上使用JAVA支持的任意面板。轻量级组件的缺点则是执行速度较慢,优点就是可以在所有平台上采用统一的行为。

概念解析:

JFrame – java的GUI程序的基本思路是以JFrame为基础,它是屏幕上window的对象,能够最大化、最小化、关闭。

JPanel – Java图形用户界面(GUI)工具包swing中的面板容器类,包含在javax.swing 包中,可以进行嵌套,功能是对窗体中具有相同逻辑功能的组件进行组合,是一种轻量级容器,可以加入到JFrame窗体中。。

JLabel – JLabel 对象可以显示文本、图像或同时显示二者。可以通过设置垂直和水平对齐方式,指定标签显示区中标签内容在何处对齐。默认情况下,标签在其显示区内垂直居中对齐。默认情况下,只显示文本的标签是开始边对齐;而只显示图像的标签则水平居中对齐。

JTextField –一个轻量级组件,它允许编辑单行文本。

JPasswordField – 允许我们输入了一行字像输入框,但隐藏星号(*) 或点创建密码(密码)

JButton – JButton 类的实例。用于创建按钮类似实例中的 "Login"。


网站名称:客户入住登记java代码 客户入住登记java代码是什么
文章链接:http://cdkjz.cn/article/doiceoh.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220