aboutsummaryrefslogtreecommitdiff
path: root/src/portfolio1
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2025-05-01 02:15:59 +0200
committerJonas Smedegaard <dr@jones.dk>2025-05-01 02:18:01 +0200
commit94f7348c379f16036e67dce1ad94be274fc84ec8 (patch)
tree8c268fc147e275efc020a4fec963d7feb5f6ef9c /src/portfolio1
parenta17f4b5b8279488e5c9682b31f0c2d40a6080fbb (diff)
add/update build and zip generation routines
Diffstat (limited to 'src/portfolio1')
-rw-r--r--src/portfolio1/Activity.java15
-rw-r--r--src/portfolio1/BachelorProject.java8
-rw-r--r--src/portfolio1/BasicCourse.java8
-rw-r--r--src/portfolio1/BasicProject.java8
-rw-r--r--src/portfolio1/Course.java8
-rw-r--r--src/portfolio1/ElectiveCourse.java8
-rw-r--r--src/portfolio1/Main.java39
-rw-r--r--src/portfolio1/MainTest.java42
-rw-r--r--src/portfolio1/Programme.java87
-rw-r--r--src/portfolio1/Project.java8
-rw-r--r--src/portfolio1/SubjectModuleCourse.java8
-rw-r--r--src/portfolio1/SubjectModuleProject.java8
12 files changed, 247 insertions, 0 deletions
diff --git a/src/portfolio1/Activity.java b/src/portfolio1/Activity.java
new file mode 100644
index 0000000..0f5c929
--- /dev/null
+++ b/src/portfolio1/Activity.java
@@ -0,0 +1,15 @@
+public abstract class Activity {
+ int ects;
+ String name;
+ public Activity(int ects, String name) {
+ this.ects = ects;
+ this.name = name;
+ }
+ public String toString(){
+ return name + ", " + ects + " ECTS";
+ }
+
+ public int getEcts(){
+ return this.ects;
+ }
+}
diff --git a/src/portfolio1/BachelorProject.java b/src/portfolio1/BachelorProject.java
new file mode 100644
index 0000000..3c2e7ec
--- /dev/null
+++ b/src/portfolio1/BachelorProject.java
@@ -0,0 +1,8 @@
+public class BachelorProject extends Project {
+ public BachelorProject(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Bachelor " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/BasicCourse.java b/src/portfolio1/BasicCourse.java
new file mode 100644
index 0000000..bf3e64b
--- /dev/null
+++ b/src/portfolio1/BasicCourse.java
@@ -0,0 +1,8 @@
+public class BasicCourse extends Course {
+ public BasicCourse(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Basic " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/BasicProject.java b/src/portfolio1/BasicProject.java
new file mode 100644
index 0000000..4017577
--- /dev/null
+++ b/src/portfolio1/BasicProject.java
@@ -0,0 +1,8 @@
+public class BasicProject extends Project {
+ public BasicProject(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Basic " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/Course.java b/src/portfolio1/Course.java
new file mode 100644
index 0000000..66acd3f
--- /dev/null
+++ b/src/portfolio1/Course.java
@@ -0,0 +1,8 @@
+public class Course extends Activity {
+ public Course(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Course: " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/ElectiveCourse.java b/src/portfolio1/ElectiveCourse.java
new file mode 100644
index 0000000..6b23c84
--- /dev/null
+++ b/src/portfolio1/ElectiveCourse.java
@@ -0,0 +1,8 @@
+public class ElectiveCourse extends Course {
+ public ElectiveCourse(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Elective " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/Main.java b/src/portfolio1/Main.java
new file mode 100644
index 0000000..8bb4482
--- /dev/null
+++ b/src/portfolio1/Main.java
@@ -0,0 +1,39 @@
+public class Main {
+ public static void main(String[] args) {
+ Programme HumTek = new Programme();
+ // adds courses and projects to arraylist
+ HumTek.add(
+ // semester 1
+ new BasicCourse(5, "Design"),
+ new BasicCourse(5, "Design og Bæredygtighed"),
+ new BasicCourse(5, "Mennesker og Teknologi"),
+ new BasicProject(15, "BP1: Projekt med fokus på design"),
+ // semester 2
+ new BasicCourse(5, "Teknologi"),
+ new BasicCourse(5, "Temakursus i teknologi"),
+ new BasicCourse(5, "Mennesker, teknologi og samfund"),
+ new BasicProject(15, "BP2: Projekt med fokus på teknologi"),
+ // semester 3
+ new SubjectModuleCourse(5, "Essential computing"),
+ new SubjectModuleCourse(5, "Filosofi- og videnskabshistorie indtil 1600"),
+ new BasicCourse(5, "Videnskabsteori"),
+ new BasicProject(15, "BP3: Projekt med fokus på mennesker og teknologi"),
+ // semester 4
+ new SubjectModuleCourse(5, "Interactive digital systems"),
+ new SubjectModuleCourse(10, "Software development"),
+ new SubjectModuleProject(15, "Subject module project in computer science"),
+ // semester 5
+ new SubjectModuleCourse(5, "Filosofihistorie 1600-1900"),
+ new SubjectModuleCourse(5, "Etik og politisk filosofi"),
+ new SubjectModuleCourse(5, "Metafysik og erkendelseteori"),
+ new SubjectModuleProject(15, "Fagmodulprojekt i filosofi og videnskabsteori"),
+ // semester 6
+ new ElectiveCourse(5, "Valgfrit kursus 1"),
+ new ElectiveCourse(5, "Valgfrit kursus 2"),
+ new BasicCourse(5, "Profilkursus"),
+ new BachelorProject(15, "Bachelorprojekt")
+ );
+ System.out.println(HumTek);
+ if (HumTek.isValid()){System.out.println("We good");}
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/MainTest.java b/src/portfolio1/MainTest.java
new file mode 100644
index 0000000..2901ef9
--- /dev/null
+++ b/src/portfolio1/MainTest.java
@@ -0,0 +1,42 @@
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class MainTest {
+
+ @Test
+ void testValid() {
+ Programme testProg = new Programme();
+ for (int i = 0; i < 18; i++) {
+ testProg.add(new Course(5, "course " + i));
+ }
+ for (int j = 0; j < 6; j++) {
+ testProg.add(new Project(15, "project " + j));
+ }
+ assertEquals(false, testProg.isValid());
+ }
+
+ @Test
+ void testCorrectProgramme() {
+ Programme testProg = new Programme();
+ for (int i = 0; i < 8; i++) {
+ testProg.add(new BasicCourse(5, "Basic Course " + i));
+ }
+ for (int j = 0; j < 3; j++) {
+ testProg.add(new BasicProject(15, "Basic Project " + j));
+ }
+ for (int i = 0; i < 8; i++) {
+ testProg.add(new SubjectModuleCourse(5, "Subject Module Course " + i));
+ }
+ for (int i = 0; i < 2; i++) {
+ testProg.add(new SubjectModuleProject(15, "Subject Module Project " + i));
+ }
+ for (int i = 0; i < 2; i++) {
+ testProg.add(new ElectiveCourse(5, "Elective Course " + i));
+ }
+ testProg.add(new BachelorProject(15, "Bachelor Project"));
+ assertEquals(true, testProg.isValid());
+ }
+
+}
+
diff --git a/src/portfolio1/Programme.java b/src/portfolio1/Programme.java
new file mode 100644
index 0000000..8847c89
--- /dev/null
+++ b/src/portfolio1/Programme.java
@@ -0,0 +1,87 @@
+import java.util.ArrayList;
+import java.util.Iterator;
+
+public class Programme {
+ static ArrayList<Activity> activities = new ArrayList<>();
+
+ public Programme() {
+ // Reset the activities list when a new Programme is created
+ activities.clear();
+ }
+
+ // Performs a check to see if the programme is valid
+ public boolean isValid() {
+ //Initializes variables we need to test
+ int sumProject = 0;
+ int sumCourse = 0;
+ int sumBasicCourse = 0;
+ int countSubjectModuleProject = 0;
+ int sumSubjectModuleCourse = 0;
+ int countBachelorProject = 0;
+ int countBasicProject = 0;
+ int sumElectiveCourse = 0;
+
+ //The program looks through every activity in the programme list and checks for specific classes
+ for (Activity activity : activities) {
+ String activityString = activity.toString();
+
+ // Check for specific types based on toString() output
+ if (activityString.startsWith("Basic Course:")) {
+ sumBasicCourse += activity.getEcts();
+ sumCourse += activity.getEcts();
+ } else if (activityString.startsWith("Subject Module Course:")) {
+ sumSubjectModuleCourse += activity.getEcts();
+ sumCourse += activity.getEcts();
+ } else if (activityString.startsWith("Elective Course:")) {
+ sumElectiveCourse += activity.getEcts();
+ sumCourse += activity.getEcts();
+ } else if (activityString.startsWith("Course:")) {
+ sumCourse += activity.getEcts();
+ } else if (activityString.startsWith("Bachelor Project:")) {
+ countBachelorProject += 1;
+ sumProject += activity.getEcts();
+ } else if (activityString.startsWith("Subject Module Project:")) {
+ countSubjectModuleProject++;
+ sumProject += activity.getEcts();
+ } else if (activityString.startsWith("Basic Project:")) {
+ countBasicProject++;
+ sumProject += activity.getEcts();
+ } else if (activityString.startsWith("Project:")) {
+ sumProject += activity.getEcts();
+ }
+ }
+
+ //It returns a boolean depending on the parameters are correct
+ /* A valid programme must have activities from two subject modules,
+ three basic projects, a bachelor project,
+ and a further 50 ECTS of courses where at least 40 ECTS are basic courses.
+ In a valid programme no activity can appear twice */
+
+ return (
+ sumCourse == 90
+ && sumProject == 90
+ && sumBasicCourse == 40
+ && countSubjectModuleProject == 2
+ && sumSubjectModuleCourse == 40
+ && countBachelorProject == 1);
+
+ }
+
+ public void add(Activity... activitiesArray) {
+ for (Activity e : activitiesArray) {
+ this.activities.add(e);
+ }
+ }
+
+ public String toString() {
+ StringBuilder ret = new StringBuilder();
+ Iterator<Activity> it = activities.iterator();
+ while (it.hasNext()) {
+ ret.append(it.next());
+ if (it.hasNext()) {
+ ret.append(System.lineSeparator());
+ }
+ }
+ return ret.toString();
+ }
+}
diff --git a/src/portfolio1/Project.java b/src/portfolio1/Project.java
new file mode 100644
index 0000000..c56fd86
--- /dev/null
+++ b/src/portfolio1/Project.java
@@ -0,0 +1,8 @@
+public class Project extends Activity {
+ public Project(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Project: " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/SubjectModuleCourse.java b/src/portfolio1/SubjectModuleCourse.java
new file mode 100644
index 0000000..64cd81b
--- /dev/null
+++ b/src/portfolio1/SubjectModuleCourse.java
@@ -0,0 +1,8 @@
+public class SubjectModuleCourse extends Course {
+ public SubjectModuleCourse(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Subject Module " + super.toString();
+ }
+} \ No newline at end of file
diff --git a/src/portfolio1/SubjectModuleProject.java b/src/portfolio1/SubjectModuleProject.java
new file mode 100644
index 0000000..f44884c
--- /dev/null
+++ b/src/portfolio1/SubjectModuleProject.java
@@ -0,0 +1,8 @@
+public class SubjectModuleProject extends Project {
+ public SubjectModuleProject(int ects, String name) {
+ super(ects, name);
+ }
+ public String toString() {
+ return "Subject Module " + super.toString();
+ }
+} \ No newline at end of file