Guest User

Untitled

a guest
Jun 21st, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. class c {
  2. //Vars
  3. //-Klassvars
  4. public static int totAntal;
  5.  
  6. //-Instansvars
  7. public int cID;
  8.  
  9.  
  10. //Konstruktorer
  11. public c() {
  12. totAntal++;
  13. this.cID = totAntal;
  14. }
  15.  
  16.  
  17. //Metoder
  18. //-KlassMetoder
  19. public static void Total() {
  20. System.out.println(c.totAntal);
  21. }
  22.  
  23. //-InstansMetoder
  24. public int CheckID() {
  25. return cID;
  26. }
  27. }
  28.  
  29. public class Sid130 {
  30. public static void main(String []args) {
  31. c c1 = new c();
  32. c c2 = new c();
  33. c c3 = new c();
  34.  
  35. c.Total();
  36.  
  37. c c4 = new c();
  38. c c5 = new c();
  39.  
  40. c.Total();
  41.  
  42. System.out.println("ID #1 = " + c1.CheckID());
  43. System.out.println("ID #4 = " + c4.CheckID());
  44. System.out.println("ID #5 = " + c5.CheckID());
  45. }
  46. }
Add Comment
Please, Sign In to add comment