From ea7fa5a536a0f2e8f06ec5e95fc4f421d40e6790 Mon Sep 17 00:00:00 2001 From: Adi-Sin101 Date: Thu, 21 Aug 2025 18:59:28 +0600 Subject: [PATCH 1/5] Add Student class with constructors, getters, setters --- src/Features/Student.java | 80 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/Features/Student.java diff --git a/src/Features/Student.java b/src/Features/Student.java new file mode 100644 index 000000000000..6fee9bf31ffd --- /dev/null +++ b/src/Features/Student.java @@ -0,0 +1,80 @@ +public class Student { + + private String id; + private String name; + private String email; + private String department; + private double gpa; + + // No-arg constructor + public Student() { + } + + // Parameterized constructor + public Student(String id, String name, String email, String department, double gpa) { + this.id = id; + this.name = name; + this.email = email; + this.department = department; + this.gpa = gpa; + } + + // Copy constructor + public Student(Student other) { + if (other != null) { + this.id = other.id; + this.name = other.name; + this.email = other.email; + this.department = other.department; + this.gpa = other.gpa; + } + } + + // Getters + public String getId() { return id; } + public String getName() { return name; } + public String getEmail() { return email; } + public String getDepartment() { return department; } + public double getGpa() { return gpa; } + + // Setters + public void setId(String id) { this.id = id; } + public void setName(String name) { this.name = name; } + public void setEmail(String email) { this.email = email; } + public void setDepartment(String department) { this.department = department; } + public void setGpa(double gpa) { + if (gpa < 0.0) gpa = 0.0; + if (gpa > 4.0) gpa = 4.0; + this.gpa = gpa; + } + + // Convenience builder-style methods (optional chaining) + public Student withId(String id) { setId(id); return this; } + public Student withName(String name) { setName(name); return this; } + public Student withEmail(String email) { setEmail(email); return this; } + public Student withDepartment(String department) { setDepartment(department); return this; } + public Student withGpa(double gpa) { setGpa(gpa); return this; } + + @Override + public String toString() { + return "Student{id='" + id + '\'' + + ", name='" + name + '\'' + + ", email='" + email + '\'' + + ", department='" + department + '\'' + + ", gpa=" + gpa + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Student)) return false; + Student s = (Student) o; + return (id != null && id.equals(s.id)); + } + + @Override + public int hashCode() { + return id == null ? 0 : id.hashCode(); + } +} From d25a7d2c315c7085c1dd92a431b3642750944ed7 Mon Sep 17 00:00:00 2001 From: Adi-Sin101 Date: Thu, 21 Aug 2025 19:02:39 +0600 Subject: [PATCH 2/5] Add Calculator class with basic arithmetic methods --- src/Features/Calculator.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/Features/Calculator.java diff --git a/src/Features/Calculator.java b/src/Features/Calculator.java new file mode 100644 index 000000000000..63b13e07548d --- /dev/null +++ b/src/Features/Calculator.java @@ -0,0 +1,21 @@ +public class Calculator { + + public double add(double a, double b) { + return a + b; + } + + public double subtract(double a, double b) { + return a - b; + } + + public double multiply(double a, double b) { + return a * b; + } + + public double divide(double a, double b) { + if (b == 0.0) { + throw new IllegalArgumentException("Division by zero"); + } + return a / b; + } +} From 2d52b3ba7b403fbe5fa8c2f0df48d2eeda6a30a6 Mon Sep 17 00:00:00 2001 From: Adi-Sin101 Date: Thu, 21 Aug 2025 19:13:41 +0600 Subject: [PATCH 3/5] Main: add logging and tweak divide message --- src/Features/Calculator.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/Features/Calculator.java diff --git a/src/Features/Calculator.java b/src/Features/Calculator.java new file mode 100644 index 000000000000..d160eadb9d0b --- /dev/null +++ b/src/Features/Calculator.java @@ -0,0 +1,23 @@ +public class Calculator { + + public double add(double a, double b) { + System.out.println("Main branch: adding"); + return a + b; + } + + public double subtract(double a, double b) { + System.out.println("Main branch: subtracting"); + return a - b; + } + + public double multiply(double a, double b) { + return a * b; + } + + public double divide(double a, double b) { + if (b == 0.0) { + throw new IllegalArgumentException("Division by zero (main)"); + } + return a / b; + } +} From 6d5c057073089bc77844ed6aa05e7a3815295cf6 Mon Sep 17 00:00:00 2001 From: Adi-Sin101 Date: Thu, 21 Aug 2025 19:26:57 +0600 Subject: [PATCH 4/5] Add Grade class with letter/GPA conversion and averaging --- src/Features/Grade.java | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Features/Grade.java diff --git a/src/Features/Grade.java b/src/Features/Grade.java new file mode 100644 index 000000000000..c9bb3b01c325 --- /dev/null +++ b/src/Features/Grade.java @@ -0,0 +1,46 @@ +public class Grade { + + // Simple numeric -> letter grade + public String toLetter(double score) { + if (score < 0 || score > 100) { + throw new IllegalArgumentException("Score must be 0..100"); + } + if (score >= 90) return "A"; + if (score >= 80) return "B"; + if (score >= 70) return "C"; + if (score >= 60) return "D"; + return "F"; + } + + // GPA points (typical 4.0 scale) + public double toGpaPoints(double score) { + String letter = toLetter(score); + switch (letter) { + case "A": return 4.0; + case "B": return 3.0; + case "C": return 2.0; + case "D": return 1.0; + default: return 0.0; + } + } + + // Average of array + public double average(double[] scores) { + if (scores == null || scores.length == 0) { + throw new IllegalArgumentException("Scores required"); + } + double sum = 0; + for (double s : scores) { + if (s < 0 || s > 100) { + throw new IllegalArgumentException("Score out of range: " + s); + } + sum += s; + } + return sum / scores.length; + } + + // Average letter + public String averageLetter(double[] scores) { + return toLetter(average(scores)); + } +} \ No newline at end of file From 39582865642c8b4857b93604caca6e21616c4452 Mon Sep 17 00:00:00 2001 From: Adi-Sin101 Date: Thu, 21 Aug 2025 19:42:09 +0600 Subject: [PATCH 5/5] Add ignore rule for ignore.txt --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index eb9d33c78a33..b9fbd63e6184 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ /gradle/wrapper/gradle-wrapper.properties +# Ignore temp notes file +ignore.txt + ##----------Android---------- *.apk *.ap_