Added USOS mockup project

This commit is contained in:
Arkadiusz Hypki 2024-03-04 16:19:39 +01:00
parent 324989f8ae
commit 8323cbba7f
7 changed files with 153 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,5 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@ -0,0 +1,8 @@
package net.hypki.UsosMockup.db;
import net.hypki.UsosMockup.modelobjects.DbObject;
public interface Db {
void save(DbObject value);
DbObject get(String key);
}

View File

@ -0,0 +1,32 @@
package net.hypki.UsosMockup.modelobjects;
public class Classroom extends DbObject {
private String location = null;
private int maxCapacity = 30;
public Classroom(String location) {
this.location = location;
}
public int getMaxCapacity() {
return maxCapacity;
}
public void setMaxCapacity(int maxCapacity) {
this.maxCapacity = maxCapacity;
}
@Override
String getKey() {
return getLocation();
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
}

View File

@ -0,0 +1,57 @@
package net.hypki.UsosMockup.modelobjects;
import java.util.ArrayList;
import java.util.List;
public class Course extends DbObject {
private String name = null;
private int hours = 30;
private Classroom classroom;
private List<Student> students = null;
public Course(String name) {
this.name = name;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
public Classroom getClassroom() {
return classroom;
}
public void setClassroom(Classroom classroom) {
this.classroom = classroom;
}
public List<Student> getStudents() {
if (students == null)
students = new ArrayList<>();
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
@Override
String getKey() {
return getName();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,5 @@
package net.hypki.UsosMockup.modelobjects;
public abstract class DbObject {
abstract String getKey();
}

View File

@ -0,0 +1,35 @@
package net.hypki.UsosMockup.modelobjects;
public class Student extends DbObject {
private String name = null;
private String surname = null;
public Student(String name, String surname) {
this.name = name;
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
// TODO check if it is not empty
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
@Override
String getKey() {
return getName() + " " + getSurname();
}
}