I am writing a springboot application that should calculate the grade of a student. You should read the name of the student from command line, and call an API that will return the student ID in JSON. Then I will take the Student ID and call another API that would return the total of the student Marks in JSON. Then I should calculate the grade accordingly. The calculation is as follow: F=<60, D=<65, C=< 75, B=<85, A=<100. Below is my hypothetical view of how I will write the project, I think I know how to write the code that will function, but I am stuck with what is the best skeleton for the project or design of classes. Below is how I think it should be written.
@Controller
// Rest call to the Student API
public class StudentController {
private static final Logger log = LoggerFactory.getLogger(ClientController.class);
private RestOperations rest;
private Config config; //to read the URL
.....
@Controller
// Rest call to the grades API
public class GradsController
{
private static final Logger log = LoggerFactory.getLogger(ClientController.class);
private RestOperations rest;
private Config config; //to read the URL
.....
Configuration
@ConfigurationProperties(prefix="api.call")
public class Config {
private String URL;
.....
public class Student {
@JsonProperty("Data")
private Elements[] elements;
.......
public class Grads {
@JsonProperty("Subjects")
private String[] subjects;
.......
@Service
public class CalculateGrade {
private String marks;
private HashMap <String, Integer> gradeMap;
CalculateGrade( String marks)
{
this.marks = marks;
this.carName = carName;
fillMap();
}
private void fillMap()
{
gradeMap= new HashMap<>();
gradeMap.put("A",100);
gradeMap.put("B", 85 );
..........
}
public String getGrade()
{
// do calculations;
}
@SpringBootApplication
@ConfigurationPropertiesScan ("Config")
public class MyApplication {
private static final Logger log = LoggerFactory.getLogger(MyApplication.class);
@Autowired StudentController StudentController;
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}