Employee.log=log

Employee e1 = new Employee()
Employee e2 = new Employee()
e1.name = "A"
e1.salary = 100 e2.name = "B"
e2.salary = 200 e1.printName()
e2.printName()
def newSalary = e1.increaseSalary(100)
log.info "New salary of A is $newSalary"
e2.increaseSalary(100) log.info "Salary of $e1.name is $e1.salary"
log.info "Salary of $e2.name is $e2.salary" class Employee {
def static log
def name
def salary public void printName(){
log.info name
} public int increaseSalary(amt){
salary = salary+amt
return salary
}
}

Run Result:

Tue Oct 06 19:24:47 CST 2015:INFO:A
Tue Oct 06 19:24:47 CST 2015:INFO:B
Tue Oct 06 19:24:47 CST 2015:INFO:New salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of A is 200
Tue Oct 06 19:24:47 CST 2015:INFO:Salary of B is 300

[Training Video - 4] [Groovy] Function in detail的更多相关文章

  1. [Training Video - 3] [Groovy in Detail] Non-static and Static functions, initializing log inside class

    log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...

  2. [Training Video - 3] [Groovy in Detail] Non-static and Static variables, objects and object referances

    log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...

  3. [Training Video - 3] [Groovy in Detail] What is a groovy class ?

    log.info "starting" // we use class to create objects of a class Planet p1 = new Planet() ...

  4. [Training Video - 2] [Groovy Introduction]

    Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...

  5. [Training Video - 4] [Groovy] Optional parameter in groovy

    Employee.log=log Employee e1 = new Employee() log.info e1.add(1,2,3,4) // optional parameters in gro ...

  6. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Exception Handling in groovy

    def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"X ...

  7. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] HashSet and Hashtable

    Hashset: HashSet set = new HashSet() set.add("India") set.add("USA") set.add(&qu ...

  8. [Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Array and ArrayList

    Array: def x = new String[5] x[0] = "India" x[1] = "USA" x[2] = "Korea" ...

  9. [Training Video - 4] [Groovy] String Functions

    def x="I like to read books before bed" def temp = x.split(" ") log.info "S ...

随机推荐

  1. java,js 解unicode

    import java.util.regex.Matcher; import java.util.regex.Pattern; public class UnicodeDecodeDataConver ...

  2. 十八 线程暂停 suspend/ resume

    1  Suspend.resume 的缺点1 :独占!  线程执行到同步块中,如果线程暂停了,不会释放锁. 比如,比如System.out.println()方法就是一个同步方法, 如果线程调用Sys ...

  3. user

    test|123456 raolan|123456 test2|456123

  4. Varnish,Nginx搭建缓存服务器

    Varnish,Nginx搭建缓存服务器 一. varnish 1.安装pcre库,兼容正则表达式 # tar -zxvf pcre-8.10.tar.gz # cd pcre-8.10 # ./co ...

  5. FastQC 测序质量

    文章转载于 Original 2017-07-06 Jolvii 生信百科 介绍一下如何理解 FastQC 各模块的结果 FastQC 的使用 FastQC的安装介绍请看这里.FastQC 支持 fa ...

  6. GNU/Linux LVM 原理图释

    逻辑卷管理器(英语:Logical Volume Manager,缩写为LVM),又译为逻辑卷宗管理器.逻辑扇区管理器.逻辑磁盘管理器,是Linux核心所提供的逻辑卷管理(Logical volume ...

  7. 学习 Python 编程的 19 个资源 (转)

    学习 Python 编程的 19 个资源 2018-01-07 数据与算法之美 编译:wzhvictor,英文:codecondo segmentfault.com/a/119000000418731 ...

  8. Set8087CW

    Set8087CWThis example accesses the Floating Point Unit (FPU) control register. Try turning floating ...

  9. Windows Intel VT-x开启

    解决虚拟机安装64位系统“此主机支持 Intel VT-x,但 Intel VT-x 处于禁用状态”的问题 背景:win7 旗舰版 64位+VMware 10.0 启动虚拟机时报错 问题:已将该虚拟机 ...

  10. 网卡流量监控脚本 ( Shell )

    #!/bin/bash # Traffic Monitor # author: Xiao Guaishou get_traffic_info(){ recv=`cat /proc/net/dev | ...