zoukankan      html  css  js  c++  java
  • 18

    package room1;
    class Employee{

    String name;
    int age;
    String designation;
    double salary;

    // This is the constructor of the class Employee
    public Employee(String name){
    this.name = name;
    }
    // Assign the age of the Employee to the variable age.
    public void empAge(int empAge){
    age = empAge;
    }
    /* Assign the designation to the variable designation.*/
    public void empDesignation(String empDesig){
    designation = empDesig;
    }
    /* Assign the salary to the variable salary.*/
    public void empSalary(double empSalary){
    salary = empSalary;
    }
    /* Print the Employee details */
    public void printEmployee(){
    System.out.println("Name:"+ name );
    System.out.println("Age:" + age );
    System.out.println("Designation:" + designation );
    System.out.println("Salary:" + salary);
    }


    public static void main(String args[]){
    /* Create two objects using constructor */
    Employee empOne = new Employee("James Smith");
    Employee empTwo = new Employee("Mary Anne");

    // Invoking methods for each object created
    empOne.empAge(26);
    empOne.empDesignation("Senior Software Engineer");
    empOne.empSalary(1000);
    empOne.printEmployee();

    empTwo.empAge(21);
    empTwo.empDesignation("Software Engineer");
    empTwo.empSalary(500);
    empTwo.printEmployee();
    }
    }

  • 相关阅读:
    15.Git版本控制系统
    14.sudo 获取root权限
    13.定时任务
    12.文件权限:RWX
    相信301跳转大家都知道 rewrite
    修改mysql密码
    mod_rewrite是Apache的一个非常强大的功能
    mysql 常用命令集锦[绝对精华]
    mysql安装完之后,登陆后发现只有两个数据库
    mysql命令
  • 原文地址:https://www.cnblogs.com/acm-icpcer/p/6536317.html
Copyright © 2011-2022 走看看