Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Course {
- private long id;
- private String name;
- Course(long id,String name){
- this.id=id;
- this.name=name;
- }
- public long getId() {
- return id;
- }
- public void setId(long i) {
- id = i;
- }
- public String getName() {
- return name;
- }
- public void setName(String n) {
- name = n;
- }
- }
- Course findById(long id){
- return info[(int) id];
- }
- Course[] info = {
- new Course(1, "Matematicas"),
- new Course(2, "Biologia"),
- new Course(3, "Fisica"),
- new Course(4, "Ingles"),
- new Course(5, "Quimica")
- };
- @RequestMapping("/courses")
- Iterable<Course> findCourse() {
- List<Course> list = Arrays.asList(info);
- return (list);
- }
- @RequestMapping("/courses/{id}")
- Course findCourse(@PathVariable("id") Integer id) {
- return info[id-1];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement