Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Iterator;
  3. import java.util.HashMap;
  4. import java.util.Random;
  5.  
  6.  
  7. /**
  8. * Write a description of class Studentparty here.
  9. *
  10. * @author (your name)
  11. * @version (a version number or a date)
  12. */
  13. public class Studentparty
  14. {
  15. // instance variables - replace the example below with your own
  16. private int randomAlder;
  17. private static HashMap<String, Integer> hashMap;
  18. private final String DRIKKE = "Champagne";
  19.  
  20. /**
  21. * Constructor for objects of class Studentparty
  22. */
  23. public Studentparty()
  24. {
  25. // initialise instance variables
  26. randomAlder = new Random().nextInt(100);
  27. hashMap = new HashMap();
  28.  
  29. hashMap.put("Janne Jensen", 22);
  30. hashMap.put("Nina Julsen", 31);
  31. hashMap.put("Anders Hansen", 19);
  32. hashMap.put("Krister Kristiansaen", 29);
  33. hashMap.put("Martin Martinsen", 25);
  34. }
  35.  
  36. private void removeFromHashMap(String gjest){
  37. hashMap.remove(gjest);
  38. }
  39.  
  40. public void alleGjester(){
  41. it.Entry pair = (it.Entry)it.next();
  42. System.out.println("Gjesteliste: ");
  43.  
  44. while(it.hasNext()){
  45. Integer fornavn = Map.next();
  46. System.out.println(fornavn + "har vunnet et gavekort for beste antrekk!" + hashMap.get(String));
  47. }
  48. }
  49.  
  50. public static void main(String[] args) {
  51. System.out.println("Tilfeldig alder: " + object.randomAlder);
  52. System.out.println("Hvem er 19 år?" + hashMap.get(19));
  53. System.out.println("Hvilken drikke får vi i dag?" + object.DRIKKE);
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60. /**
  61. * An example of a method - replace this comment with your own
  62. *
  63. * @param y a sample parameter for a method
  64. * @return the sum of x and y
  65. */
  66. public int sampleMethod(int y)
  67. {
  68. // put your code here
  69. return x + y;
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement