feat: adding class student and data source interface
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
public interface DataSource {
|
||||
MyList<Student> fill(int size);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class FileDataSource implements DataSource{
|
||||
private String path;
|
||||
|
||||
public FileDataSource(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MyList<Student> fill(int size) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
||||
// to see how IntelliJ IDEA suggests fixing it.
|
||||
System.out.printf("Hello and welcome!");
|
||||
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
||||
System.out.println("i = " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class ManualDataSource implements DataSource{
|
||||
@Override
|
||||
public MyList<Student> fill(int size) {
|
||||
String strToParse;
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
while(true){
|
||||
strToParse = scanner.next();
|
||||
if (strToParse.equals("0"))
|
||||
break;
|
||||
}
|
||||
scanner.close();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
public class MyList <T>{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public class RandomDataSource implements DataSource{
|
||||
@Override
|
||||
public MyList<Student> fill(int size) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Student {
|
||||
private final String groupNumber;
|
||||
private final double averageGrade;
|
||||
private final String recordBookNumber;
|
||||
|
||||
public Student(String groupNumber, double averageGrade, String recordBookNumber) {
|
||||
this.groupNumber = groupNumber;
|
||||
this.averageGrade = averageGrade;
|
||||
this.recordBookNumber = recordBookNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
public class StudentBuilder {
|
||||
private String groupNumber;
|
||||
private double averageGrade;
|
||||
private String recordBookNumber;
|
||||
|
||||
public void setGroupNumber(String groupNumber) {
|
||||
this.groupNumber = groupNumber;
|
||||
}
|
||||
|
||||
public void setAverageGrade(double averageGrade) {
|
||||
this.averageGrade = averageGrade;
|
||||
}
|
||||
|
||||
public void setRecordBookNumber(String recordBookNumber) {
|
||||
this.recordBookNumber = recordBookNumber;
|
||||
}
|
||||
|
||||
public Student build(){
|
||||
//TODO: Реализовать проверку на корректность введенных значений
|
||||
|
||||
return new Student(groupNumber,averageGrade, recordBookNumber);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user