customer.java

来自「java程序设计 清华出版社 孙燮华老师编写的程序源代码」· Java 代码 · 共 40 行

JAVA
40
字号
//Customer.java
class Customer{
  String name, address, telephone; //定义成员变量
  //定义成员方 
  String getName(){
    return name;
  }
  String getAddress(){
    return address;
  }
  String getTelephone(){
    return telephone;
  }
  void setName(String name){
    this.name = name;
  }
  void setAddress(String address){
    this.address = address;
  }
  void setTelephone (String telephone){
    this.telephone = telephone;
  }

  public static void main(String[] args){
    Customer customer1 = new Customer();//实例化Customer类对象customer1
        
    customer1.setName("Wang Ming");           //调用类成员方法
    customer1.setAddress("#188 Beijing Road");//调用类成员方法
    customer1.setTelephone("0571-23503545");  //调用类成员方法

    System.out.print("The customer is ");
    System.out.println(customer1.getName());
    System.out.print("The customer address is ");
    System.out.println(customer1.getAddress());
    System.out.print("The customer telephone is ");
    System.out.println(customer1.getTelephone());
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?