Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 KB | None | 0 0
  1. import model.Line;
  2. import model.Osoba;
  3. import model.Point;
  4. import model.StudentClass;
  5. import model.Teacher;
  6.  
  7. public class Main {
  8.  
  9. public static void main(String[] args) {
  10. /*
  11. * Teacher mainTeacher = new Teacher("Slavica", "Knezevic", "Matematika");
  12. * Teacher teacher = new Teacher(); teacher.setFirstName("Mia");
  13. * teacher.setLastName("Koncar"); teacher.setSubject("Engleski"); Osoba osoba =
  14. * new Osoba("Test" , "test");
  15. *
  16. * StudentClass studentClass = new StudentClass(22,mainTeacher, teacher);
  17. *
  18. * System.out.println(studentClass.getFavoriteTeacher());
  19. * System.out.println(osoba.getFirstName());
  20. */
  21. /*
  22. * Point point = new Point(5 , 7); System.out.println(point.distance(9, 11));
  23. */
  24.  
  25. /*
  26. * Teacher teacher = new Teacher("Slavica", "Knezevic", "Matematika", 22);
  27. * Teacher teacher2 = new Teacher("Zorica", "Krneta", "Matematika", 22);
  28. *
  29. * System.out.println(teacher); System.out.println(teacher2);
  30. *
  31. * if(teacher.getAge() == teacher2.getAge()) {
  32. * System.out.println(teacher.getAge() + " = " + teacher2.getAge()); }
  33. *
  34. * String a = new String("Matematika"); String b = new String("Matematika");
  35. *
  36. * if(a.equals(b)) { System.out.println(a + " = " + b); }else {
  37. * System.out.println(a + " != " + b); }
  38. */
  39.  
  40. Point startPointLine1 = new Point(7, 4);
  41. Point startPointLine2 = new Point(7, 4);
  42. Point endPointLine1 = new Point(8, 2);
  43. Point endPointLine2 = new Point(8, 3);
  44.  
  45. Line line1 = new Line(startPointLine1, endPointLine1);
  46. Line line2 = new Line(startPointLine2, endPointLine2);
  47.  
  48. if (line1.equals(line1)) {
  49. System.out.println("iste su");
  50. } else {
  51. System.out.println("nisu iste");
  52. }
  53.  
  54. }
  55.  
  56. }
  57.  
  58. /////////////////
  59.  
  60. package model;
  61.  
  62. public class Line {
  63.  
  64. private Point startPoint;
  65. private Point endPoint;
  66. private boolean selected;
  67.  
  68. public Point getStartPoint() {
  69. return startPoint;
  70. }
  71.  
  72. public void setStartPoint(Point startPoint) {
  73. this.startPoint = startPoint;
  74. }
  75.  
  76. public Point getEndPoint() {
  77. return endPoint;
  78. }
  79.  
  80. public void setEndPoint(Point endPoint) {
  81. this.endPoint = endPoint;
  82. }
  83.  
  84. public boolean isSelected() {
  85. return selected;
  86. }
  87.  
  88. public void setSelected(boolean selected) {
  89. this.selected = selected;
  90. }
  91.  
  92. public Line(Point startPoint, Point endPoint, boolean selected) {
  93. super();
  94. this.startPoint = startPoint;
  95. this.endPoint = endPoint;
  96. this.selected = selected;
  97. }
  98.  
  99. public Line(Point startPoint, Point endPoint) {
  100. super();
  101. this.startPoint = startPoint;
  102. this.endPoint = endPoint;
  103. }
  104.  
  105. public Line() {
  106. super();
  107. }
  108.  
  109. public boolean equals(Line line) {
  110. if (this.startPoint.equals(line.getStartPoint()) && line.getEndPoint().equals(this.endPoint)) {
  111. return true;
  112. }
  113. return false;
  114. }
  115.  
  116. }
  117.  
  118. ////////////////////
  119.  
  120. package model;
  121.  
  122. public class Point {
  123.  
  124. private int x;
  125. private int y;
  126. private boolean selected;
  127.  
  128. public Point() {
  129. super();
  130. }
  131.  
  132. public Point(int x, int y, boolean selected) {
  133. super();
  134. this.x = x;
  135. this.y = y;
  136. this.selected = selected;
  137. }
  138.  
  139. public Point(int x, int y) {
  140. super();
  141. this.x = x;
  142. this.y = y;
  143. }
  144.  
  145. public int getX() {
  146. return x;
  147. }
  148.  
  149. public void setX(int x) {
  150. this.x = x;
  151. }
  152.  
  153. public int getY() {
  154. return y;
  155. }
  156.  
  157. public void setY(int y) {
  158. this.y = y;
  159. }
  160.  
  161. public boolean isSelected() {
  162. return selected;
  163. }
  164.  
  165. public void setSelected(boolean selected) {
  166. this.selected = selected;
  167. }
  168.  
  169. public double distance(int x, int y) {
  170. int dx = this.x - x;
  171. int dy = this.y - y;
  172. return Math.sqrt(dx * dx + dy * dy);
  173. }
  174.  
  175. public boolean equals(Point point) {
  176. System.out.println("Parametar x = " + point.getX());
  177. System.out.println("Parametar y = " + point.getY());
  178. System.out.println("privatni x = " + this.x);
  179. System.out.println("privatni y = " + this.y);
  180. System.out.println("------------------------");
  181. if(point.getX() == this.x && point.getY()==this.y) {
  182. return true;
  183. }
  184. return false;
  185. }
  186.  
  187. }
  188.  
  189.  
  190. /////////////////////////////////////
  191.  
  192.  
  193. package model;
  194.  
  195. public class Osoba {
  196.  
  197. protected String firstName;
  198. protected String lastName;
  199.  
  200. public Osoba() {
  201. super();
  202. }
  203.  
  204. public Osoba(String firstName, String lastName) {
  205. super();
  206. this.firstName = firstName;
  207. this.lastName = lastName;
  208. }
  209.  
  210. public String getFirstName() {
  211. return firstName;
  212. }
  213.  
  214. public void setFirstName(String firstName) {
  215. this.firstName = firstName;
  216. }
  217.  
  218. public String getLastName() {
  219. return lastName;
  220. }
  221.  
  222. public void setLastName(String lastName) {
  223. this.lastName = lastName;
  224. }
  225.  
  226. @Override
  227. public String toString() {
  228. return "Osoba [firstName=" + firstName + ", lastName=" + lastName + "]";
  229. }
  230.  
  231. }
  232.  
  233. ///////////////////////
  234.  
  235. package model;
  236.  
  237. public class StudentClass {
  238.  
  239. private int numberOfStudents;
  240. private Teacher mainTeacher;
  241. private Teacher favoriteTeacher;
  242.  
  243. public StudentClass(int numberOfStudents, Teacher mainTeacher, Teacher favoriteTeacher) {
  244. super();
  245. this.numberOfStudents = numberOfStudents;
  246. this.mainTeacher = mainTeacher;
  247. this.favoriteTeacher = favoriteTeacher;
  248. }
  249.  
  250. public StudentClass() {
  251. super();
  252. }
  253.  
  254. public int getNumberOfStudents() {
  255. return numberOfStudents;
  256. }
  257.  
  258. public void setNumberOfStudents(int numberOfStudents) {
  259. this.numberOfStudents = numberOfStudents;
  260. }
  261.  
  262. public Teacher getMainTeacher() {
  263. return mainTeacher;
  264. }
  265.  
  266. public void setMainTeacher(Teacher mainTeacher) {
  267. this.mainTeacher = mainTeacher;
  268. }
  269.  
  270. public Teacher getFavoriteTeacher() {
  271. return favoriteTeacher;
  272. }
  273.  
  274. public void setFavoriteTeacher(Teacher favoriteTeacher) {
  275. this.favoriteTeacher = favoriteTeacher;
  276. }
  277.  
  278. @Override
  279. public String toString() {
  280. return "StudentClass [numberOfStudents=" + numberOfStudents + ", mainTeacher=" + mainTeacher
  281. + ", favoriteTeacher=" + favoriteTeacher + "]";
  282. }
  283.  
  284.  
  285.  
  286.  
  287. }
  288.  
  289. ///////////////////////////////////
  290.  
  291. package model;
  292.  
  293. public class Teacher extends Osoba {
  294.  
  295. private String subject;
  296. private int age;
  297.  
  298. public Teacher(String firstName, String lastName, String subject, int age) {
  299. super();
  300. this.firstName = firstName;
  301. this.lastName = lastName;
  302. this.subject = subject;
  303. this.age = age;
  304. }
  305.  
  306. public Teacher() {
  307. super();
  308. }
  309.  
  310. public String getSubject() {
  311. return subject;
  312. }
  313.  
  314. public void setSubject(String subject) {
  315. this.subject = subject;
  316. }
  317.  
  318. public int getAge() {
  319. return age;
  320. }
  321.  
  322. public void setAge(int age) {
  323. this.age = age;
  324. }
  325.  
  326. /*
  327. @Override
  328. public String toString() {
  329. return "Teacher [subject=" + subject + ", age=" + age + ", firstName=" + firstName + ", lastName=" + lastName
  330. + "]";
  331. }
  332. */
  333.  
  334. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement