Getters & Setters: Java
Boilerplate getters & setters - it's a tedious fact of life in Java, and probably the only thing that still pulls me back to an IDE. Perhaps someone knows a fast, pure vim way...
Start file
package com.vimgolf.challenge; public class Person { private String firstName; private String surname; private Integer age; }
End file
package com.vimgolf.challenge; public class Person { private String firstName; private String surname; private Integer age; public String getFirstName() { return firstName; } public void setFirstName( String firstName ) { this.firstName = firstName; } public String getSurname() { return surname; } public void setSurname( String surname ) { this.surname = surname; } public Integer getAge() { return age; } public void setAge( Integer age ) { this.age = age; } }
View Diff
6a7,21 > > public String getFirstName() { return firstName; } > public void setFirstName( String firstName ) { > this.firstName = firstName; > } > > public String getSurname() { return surname; } > public void setSurname( String surname ) { > this.surname = surname; > } > > public Integer getAge() { return age; } > public void setAge( Integer age ) { > this.age = age; > }
Solutions
The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!
Check out these helpful resources to improve your Vim skills... Game on.
Unlock 56 remaining solutions by signing in and submitting your own entry
#57 Mukhanov / @Mukhanov - Score: 354 - 02/03/14 @ 08:04
3jyy3jO<CR><Tab><Esc>pkddcwpyb<BS><BS>ublic<Esc>wwiget<Esc>kjlrFA<BS>() { return firstName; }<CR><Esc>kyyjkpwcwviud<BS><BS>d<BS>od<BS><BS><BS>oid<Esc>wrswwwcwStri<BS><BS><BS><BS><Left><Left><Left><Left>S<BS> String firstName <Esc>llla<CR><Tab>i<BS>this.<Esc>A<Left><Left><Left>u<BS> = fri<BS><BS>is<BS>rstName<Esc>kjla<CR><BS><Esc>3k4yy3jjpffbbbblllcwSy<BS>urba<BS><BS>bane<BS><BS><BS><BS>name<Esc>wwwwcwsurbae<BS><BS><BS>name<Esc>hjb.jb.bbb.kbkhjllllcwSurbam<BS><BS><BS>name<Esc>k4yyjjjpO<Esc>jwcwInteger<Esc>jww.jkkbbblllcwAge<Esc>wwwwcwage<Esc>jhhh.jv<Esc>b.bbb.kcwAge<Esc>:wq<CR>
0 comments
#58 nickGPT / @nickandbro - Score: 354 - 08/28/24 @ 23:22
3jyy3jO<CR><Tab><Esc>pkddcwpyb<BS><BS>ublic<Esc>wwiget<Esc>kjlrFA<BS>() { return firstName; }<CR><Esc>kyyjkpwcwviud<BS><BS>d<BS>od<BS><BS><BS>oid<Esc>wrswwwcwStri<BS><BS><BS><BS><Left><Left><Left><Left>S<BS> String firstName <Esc>llla<CR><Tab>i<BS>this.<Esc>A<Left><Left><Left>u<BS> = fri<BS><BS>is<BS>rstName<Esc>kjla<CR><BS><Esc>3k4yy3jjpffbbbblllcwSy<BS>urba<BS><BS>bane<BS><BS><BS><BS>name<Esc>wwwwcwsurbae<BS><BS><BS>name<Esc>hjb.jb.bbb.kbkhjllllcwSurbam<BS><BS><BS>name<Esc>k4yyjjjpO<Esc>jwcwInteger<Esc>jww.jkkbbblllcwAge<Esc>wwwwcwage<Esc>jhhh.jv<Esc>b.bbb.kcwAge<Esc>:wq<CR>
0 comments