Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Iterator;
- import java.util.HashMap;
- import java.util.Random;
- /**
- * Write a description of class Studentparty here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Studentparty
- {
- // instance variables - replace the example below with your own
- private int randomAlder;
- private static HashMap<String, Integer> hashMap;
- private final String DRIKKE = "Champagne";
- /**
- * Constructor for objects of class Studentparty
- */
- public Studentparty()
- {
- // initialise instance variables
- randomAlder = new Random().nextInt(100);
- hashMap = new HashMap();
- hashMap.put("Janne Jensen", 22);
- hashMap.put("Nina Julsen", 31);
- hashMap.put("Anders Hansen", 19);
- hashMap.put("Krister Kristiansaen", 29);
- hashMap.put("Martin Martinsen", 25);
- }
- private void removeFromHashMap(String gjest){
- hashMap.remove(gjest);
- }
- public void alleGjester(){
- it.Entry pair = (it.Entry)it.next();
- System.out.println("Gjesteliste: ");
- while(it.hasNext()){
- Integer fornavn = Map.next();
- System.out.println(fornavn + "har vunnet et gavekort for beste antrekk!" + hashMap.get(String));
- }
- }
- public static void main(String[] args) {
- System.out.println("Tilfeldig alder: " + object.randomAlder);
- System.out.println("Hvem er 19 år?" + hashMap.get(19));
- System.out.println("Hvilken drikke får vi i dag?" + object.DRIKKE);
- }
- /**
- * An example of a method - replace this comment with your own
- *
- * @param y a sample parameter for a method
- * @return the sum of x and y
- */
- public int sampleMethod(int y)
- {
- // put your code here
- return x + y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement