Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. public class Course {
  2. private long id;
  3. private String name;
  4.  
  5. Course(long id,String name){
  6. this.id=id;
  7. this.name=name;
  8. }
  9.  
  10. public long getId() {
  11. return id;
  12. }
  13. public void setId(long i) {
  14. id = i;
  15. }
  16. public String getName() {
  17. return name;
  18. }
  19. public void setName(String n) {
  20. name = n;
  21. }
  22.  
  23. }
  24.  
  25. Course findById(long id){
  26. return info[(int) id];
  27. }
  28. Course[] info = {
  29. new Course(1, "Matematicas"),
  30. new Course(2, "Biologia"),
  31. new Course(3, "Fisica"),
  32. new Course(4, "Ingles"),
  33. new Course(5, "Quimica")
  34. };
  35.  
  36. @RequestMapping("/courses")
  37. Iterable<Course> findCourse() {
  38. List<Course> list = Arrays.asList(info);
  39. return (list);
  40.  
  41. }
  42.  
  43. @RequestMapping("/courses/{id}")
  44. Course findCourse(@PathVariable("id") Integer id) {
  45. return info[id-1];
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement