Added USOS mockup project
This commit is contained in:
parent
324989f8ae
commit
8323cbba7f
11
02_UsosMockup/UsosMockup.iml
Normal file
11
02_UsosMockup/UsosMockup.iml
Normal 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>
|
5
02_UsosMockup/src/Main.java
Normal file
5
02_UsosMockup/src/Main.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
8
02_UsosMockup/src/net/hypki/UsosMockup/db/Db.java
Normal file
8
02_UsosMockup/src/net/hypki/UsosMockup/db/Db.java
Normal 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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package net.hypki.UsosMockup.modelobjects;
|
||||
|
||||
public abstract class DbObject {
|
||||
abstract String getKey();
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user