/
LamaBucket
/
MIREA-Java-Practice
Обзор
Документация
Войти
/
LamaBucket
/
MIREA-Java-Practice
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ListTask1/Task2/TwoWayLinkedStudent.java
66 строк
1 KB
Gleb
Work on Lists Task 1
10 ноя 2024, 21:01
10 ноя 2024, 21:01
aaa8dbf
Код
Авторство
О чём код?
package ListTask1.Task2; import java.util.Scanner; public class TwoWayLinkedStudent { private String _name; private TwoWayLinkedStudent _next; private TwoWayLinkedStudent _previous; public String GetName(){ return _name; } public TwoWayLinkedStudent GetNext(){ return _next; } public TwoWayLinkedStudent GetPrevious(){ return _previous; } public void SetNext(TwoWayLinkedStudent next){ _next = next; } public void SetPrevious(TwoWayLinkedStudent previous){ _previous = previous; } public static TwoWayLinkedStudent ReadFromConsole(){ Scanner sc = new Scanner(System.in); System.out.println("Enter Student Name: "); String name = "SOMEONE"; name = sc.nextLine(); return new TwoWayLinkedStudent(name); } @Override public String toString(){ String addText = _previous == null ? "" : " (Previous is: " + _previous._name + ")"; return _name + addText; } public TwoWayLinkedStudent(String name, TwoWayLinkedStudent next) { _name = name; _next = next; } public TwoWayLinkedStudent(String name) { _name = name; } }