File: Merced.java

package info (click to toggle)
bbmap 39.20%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,024 kB
  • sloc: java: 312,743; sh: 18,099; python: 5,247; ansic: 2,074; perl: 96; makefile: 39; xml: 38
file content (47 lines) | stat: -rwxr-xr-x 1,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fun;

import java.util.HashMap;

public class Merced {

	public static void main(String[] args) {
		
		//Create a new Map, mapping Integers to Strings
		HashMap<String, Integer> map=new HashMap<String, Integer>();
		//Associate value 21 with key "Age"
//		map.put("Age", 21);
//		map.put("Weight", 130);
//		//This won't compile since 17.0 is a Double, not an int
//		map.put("Age", 17.0);
//		map.put("Age", 23);
//		//This won't compile since "Tall" is a String, not int
//		map.put("Height", "Tall");
//		//What will this return?
//		Integer age=map.get("Age");
//		//This will succeed, but return null ("None" in Python)
//		Integer ssn=map.get("SSN#");
//		//Won't compile because the return is an Integer
//		String weight=map.get("Weight");
	}
	
	class Person {
		
		Person(String name_){
			name=name_;
		}
		
		float attractiveness() {
			return looks*salary/age;
		}
		
		String name;
		int age;
		int salary;
		float looks;
		float brains;//TODO: Irrelevant, remove
		
	}
	
	HashMap<String, Person> nameTable=new HashMap<String, Person>();
	
}