fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Property {
  8. // it's empty but can hold some info, like
  9. //public Person owner; // owners handle
  10. }
  11.  
  12. class FIO extends Property {
  13. public String firstName;
  14. public String name;
  15. public String batyaName;
  16.  
  17. public FIO( String f, String s, String b ) {
  18. firstName = f;
  19. name = s;
  20. batyaName = b;
  21. }
  22. }
  23.  
  24. class DateHolder extends Property {
  25. public Date date; //does java have Date? Replace then.
  26.  
  27. public DateHolder( Date d ) {
  28. date = d;
  29. }
  30. }
  31.  
  32. class PeopleHolder extends Property {
  33. private ArrayList<Person> people;
  34.  
  35. public PeopleHolder() {
  36. people = new ArrayList<Person>();
  37. }
  38.  
  39. public PeopleHolder addPerson( Person p ) {
  40. people.add( p );
  41. return this;
  42. }
  43.  
  44. public PeopleHolder removePerson( Person p ) {
  45. // TODO
  46. return this;
  47. }
  48. }
  49.  
  50. class Description extends Property {
  51. public String description;
  52.  
  53. public Description( String d ) {
  54. description = d;
  55. }
  56. }
  57.  
  58. class Person {
  59. public String type;
  60. private HashMap<String, Property> properties;
  61.  
  62. public Person( String type ) {
  63. this.type = type;
  64. properties = new HashMap<String, Property>();
  65. }
  66.  
  67. public Person addProperty( String s, Property p ) {
  68. properties[ s ] = p;
  69. return this;
  70. }
  71. }
  72.  
  73. class PersonList {
  74. private List<Person> p;
  75.  
  76. public PersonList() {
  77. p = new ArrayList<Person>();
  78. }
  79.  
  80. // TODO: methods like get/add/remove/find/kill/etc.
  81. }
  82. class Ideone
  83. {
  84. public static void main (String[] args) throws java.lang.Exception
  85. {
  86. // TODO: write factory class
  87. Person typicalWorker = new Person( "worker" );
  88. typicalWorker.addProperty( "FIO", new FIO( "Иванов", "Иван", "Иванович" ) )
  89. .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
  90. .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) );
  91.  
  92. PeopleHolder slaves = new PeopleHolder();
  93. slaves.addPerson( typicalWorker );
  94. Person manager = new Person( "manager" );
  95. manager.addProperty( "FIO", new FIO( "Петров", "Колян", "Степанович" ) )
  96. .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
  97. .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) )
  98. .addProperty( "slaves", slaves );
  99.  
  100. Person secretary = new Person( "other" );
  101. secretary.addProperty( "FIO", new FIO( "Сидорова", "Мария", "Никитична" ) )
  102. .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
  103. .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) )
  104. .addProperty( "description", new Description( "Секретарша. Неплохо сосёт." ) );
  105.  
  106. PersonList pl = new PersonList();
  107. pl.add( typicalWorker )
  108. .add( manager )
  109. .add( secretary );
  110. }
  111. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:68: error: incompatible types
		properties[ s ] = p;
		            ^
  required: int
  found:    String
Main.java:68: error: array required, but HashMap<String,Property> found
		properties[ s ] = p;
		          ^
Main.java:90: error: cannot find symbol
					 .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) );
					                                              ^
  symbol:   variable THIS_GUY_EMPLOY_DATE
  location: class Ideone
Main.java:89: error: cannot find symbol
					 .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
					                                             ^
  symbol:   variable THIS_GUY_BIRTH_DATE
  location: class Ideone
Main.java:93: error: cannot find symbol
		slaves.add( typicalWorker );
		      ^
  symbol:   method add(Person)
  location: variable slaves of type PeopleHolder
Main.java:97: error: cannot find symbol
			   .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) )
			                                                ^
  symbol:   variable THIS_GUY_EMPLOY_DATE
  location: class Ideone
Main.java:96: error: cannot find symbol
			   .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
			                                               ^
  symbol:   variable THIS_GUY_BIRTH_DATE
  location: class Ideone
Main.java:103: error: cannot find symbol
				 .addProperty( "employ date", new DateHolder( THIS_GUY_EMPLOY_DATE ) )
				                                              ^
  symbol:   variable THIS_GUY_EMPLOY_DATE
  location: class Ideone
Main.java:102: error: cannot find symbol
				 .addProperty( "birth date", new DateHolder( THIS_GUY_BIRTH_DATE ) )
				                                             ^
  symbol:   variable THIS_GUY_BIRTH_DATE
  location: class Ideone
Main.java:107: error: cannot find symbol
		pl.add( typicalWorker )
		  ^
  symbol:   method add(Person)
  location: variable pl of type PersonList
10 errors
stdout
Standard output is empty