Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.53 KB | None | 0 0
  1. trait Debug{
  2. def debugName = "Klasa: "+this.getClass.getName
  3. def debugFields=
  4. {
  5. val list=this.getClass.getDeclaredFields
  6. for(x <- list ){
  7. {println("Pole:"+ x.getName() +" => "+x.getType.toString())}
  8. }
  9. }
  10. def debugVars=
  11. {
  12. val list=this.getClass.getDeclaredFields
  13. for(x <- list ){
  14. x.setAccessible(true)
  15. println("Pole:"+ x.getName+" =>"+x.get(this))
  16. }
  17. }
  18. }
  19.  
  20. class Point(xv: Int, yv: Int) extends Debug {
  21.     var x: Int = xv
  22.     var y: Int = yv
  23.     var a: String = "test"
  24. }
  25.  
  26. var p2: Point = new Point(3,4)
  27. p2.debugFields
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement