package ch10.collection.List;

public class Data {
	private int x;
	private int y;
	private int z;
	
	public Data(int x, int y) {
		this.x=x;
		this.y=y;
	}
	
	public void yunsan() {
		z=x+y;
	}
	
	public void disp() {
		System.out.println(x + " " + y + " " + z);
	}

	@Override
	public String toString() {
		return "Data [x=" + x + ", y=" + y + ", z=" + z + "]";
	}
	
	
	
}
package ch10.collection.Map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import ch10.collection.List.Data;

public class Ex03 {
	public static void main(String[] args) {
		Data a=new Data(10,20);
		Data b=new Data(30,40);
		Data c=new Data(50,60);
		
		HashMap<String, Data> map=new HashMap<String, Data>();
		map.put("one", a);
		map.put("tow", b);
		map.put("three", c);
		
		
		System.out.println(map.toString());
		
		Set<String> set=map.keySet();
		Iterator<String> iter=set.iterator();
		while(iter.hasNext()) {
			Data data=map.get(iter.next());
			data.yunsan();
			data.disp();
		}
		
		map.put("four", new Data(70,80));	//추가
		map.replace("two", new Data(1,2));
		map.remove("three");
		
		System.out.println(map.toString());
		
		
	}

}
{one=Data [x=10, y=20, z=0], tow=Data [x=30, y=40, z=0], three=Data [x=50, y=60, z=0]}
10 20 30
30 40 70
50 60 110
{four=Data [x=70, y=80, z=0], one=Data [x=10, y=20, z=30], tow=Data [x=30, y=40, z=70]}