> Spring Boot Framework Fresco Play Solutions - TECH UPDATE

Spring Boot Framework Fresco Play Solutions

 Spring Boot Framework Solutions 


Spring Boot is a Java-Based Framework for building Microservices. 
The Course Id is 55960. It is not difficult to clear the final Assignment. But of the members difficult to feel to clear the hands-on Questions. These Answers are very helpful who are stuck to clear those questions. 

1. Sorting list of Candidates





1.Employee.java
package com.example.demo.employee;
public class Employee implements Comparable<Employee> {

private String name;
private int age;
private int exp;
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public int getExp() {
return exp;
}
public void setExp(int exp) {
this.exp = exp;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Employee(String name, int age, int exp) {
super();
this.name = name;
this.age = age;
this.exp = exp;
}
public Employee() {
}
@Override
    public int compareTo(Employee emp) {
    //replace your comparator here
       return (this.getAge() - emp.getAge());
    }



    2.EmployeeController


package com.example.demo.employee;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
@RestController
public class EmployeeController {
@Autowired
private EmployeeService emp;
    //Put your code here
  @RequestMapping("/")
public List<Employee> getEmpList(){
    //Put your code here
    List<Employee> e = emp.getEmployees();
    Collections.sort(e);
return e;
}
}

3.EmployeeService.java
package com.example.demo.employee;

import java.util.Arrays;

import org.springframework.stereotype.Service;
import java.util.List;
import java.util.ArrayList;

@Service
public class EmployeeService {
public List<Employee> getEmployees() {
      final List<Employee> demo = new ArrayList<>();
      demo.add(new Employee("Sandhya",20,0));
      demo.add(new Employee("Kemp",24,2));
      demo.add(new Employee("Anil",22,3));
      demo.add(new Employee("Kumar",30,6));
      demo.add(new Employee("Tim",32,7));
      

      return demo;
    }
}
}


2. Accessing Values from the application. properties.file




            fresco-course = Spring Boot


3) Print contents of the list along the sublist




ContentController.java

package com.example.demo.content;

import java.util.List;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

@RestController
public class ContentController {
//Put your code here.
  @Autowired
  private ContentService cs;

  @RequestMapping("/")
  public List<Category> getContentList(){
    List<Category> c = cs.getAllContent();
    return c;
  }

}

ContentService.java

package com.example.demo.content;

import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;

import org.springframework.stereotype.Service;

@Service
public class ContentService {

    //put your code here.
  public List<Category> categories = new ArrayList<>();

public List<Category> getAllContent() {
    List<Course> courses = new ArrayList<>();
      courses.add(new Course(1,"Coursename",200,200,1001));
      courses.add(new Course(2,"Coursename",200,200,1001));
      courses.add(new Course(3,"Coursename",200,200,1001));

    List<Category> categories = new ArrayList<>();

    categories.add(new Category(1001,"Cloud Computing","network of remote servers hosted on the internet to store",courses));
    categories.add(new Category(1002,"Software","network of remote servers hosted on the internet to store",courses));
    categories.add(new Category(1003,"Networking","network of remote servers hosted on the internet to store",courses));

    return categories;
}
}

                                                                    Thank You 
Spring Boot Framework Fresco Play Solutions Spring Boot Framework Fresco Play Solutions Reviewed by TECH UPDATE on March 23, 2021 Rating: 5

No comments:

Powered by Blogger.