[Training Video - 4] [Groovy] Function in detail
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的更多相关文章
- [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() ...
- [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() ...
- [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() ...
- [Training Video - 2] [Groovy Introduction]
Building test suites, Test cases and Test steps in SOAP UI Levels : test step level test case level ...
- [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 ...
- [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 ...
- [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 ...
- [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" ...
- [Training Video - 4] [Groovy] String Functions
def x="I like to read books before bed" def temp = x.split(" ") log.info "S ...
随机推荐
- Juicer自定义函数
首先,先写自定义的方法: function (sex) { ; ; var Range = Max - Min; var Rand = Math.random(); var res = (Min + ...
- mac 终端命令行操作
1,root 切换 sudo su 2,安装brew curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 ...
- RTMP(实时信息传输协议)详解
RTMP协议是Real Time Message Protocol(实时信息传输协议)的缩写,它是由Adobe公司提出的一种应用层的协议,用来解决多媒体数据传输流的多路复用(Multiplexing) ...
- Java-Runoob-面向对象:Java 多态
ylbtech-Java-Runoob-面向对象:Java 多态 1.返回顶部 1. Java 多态 多态是同一个行为具有多个不同表现形式或形态的能力. 多态就是同一个接口,使用不同的实例而执行不同操 ...
- Codeforces-20152016-northwestern-european-regional-contest-nwerc-A题
一.题目 二.题意 (1)一开始理解成:它最多需要开多少台电脑.同时,我又有个疑问,既然是最多需要开多少台,那不变成了总共有几个人开几台是最大的结果.然后,WA了无数发.直到比赛结束......其实说 ...
- JAVA线程分析定位排查
java开发中有的时间经常遇到某个线程消耗CPU高的问题,但是不清楚这个线程在做什么. 于是网上看了一些文章,找到了一个比较靠谱的办法(Linux下,Windows同理) : 首先使用top确认是否消 ...
- MVC Html.DropDownList 和DropDownListFor 的常用方法
一.非强类型: Controller: ViewData["AreId"] = from a in rp.GetArea() select new SelectListItem { ...
- 使用Spring MVC创建 REST API
1.REST的基础知识 当谈论REST时,有一种常见的错误就是将其视为“基于URL的Web服务”——将REST作为另一种类型的远程过程调用(remote procedurecall,RPC)机制,就像 ...
- C#开发之反射的简单使用
奋斗的蘑菇 原文C#开发之反射的简单使用 以前在Windows Mobile中写过一个写好的Dll中的图片的例子,现在在项目中有接触到在一个大的窗体中,动态的加载一些窗体这样的需求.将功能按照模块的划 ...
- Android中RelativeLayout各个属性
android:layout_above="@id/xxx" --将控件置于给定ID控件之上 android:layout_below="@id/xxx" ...