diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/homework-java-ironschool.iml b/.idea/homework-java-ironschool.iml new file mode 100644 index 00000000..b107a2dd --- /dev/null +++ b/.idea/homework-java-ironschool.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..e6be3f13 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..7d988043 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Course.java b/Course.java new file mode 100644 index 00000000..c5d00e0c --- /dev/null +++ b/Course.java @@ -0,0 +1,54 @@ +import java.util.UUID; + +public class Course { + private String courseId; + private String name; + private double price; + private double moneyEarned; + private Teacher teacher; + + public Course(String name, double price) { + this.courseId = UUID.randomUUID().toString(); + this.name = name; + this.price = price; + this.moneyEarned = 0.0; + this.teacher = null; + } + + public String getCourseId() { + return courseId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + this.price = price; + } + + public double getMoneyEarned() { + return moneyEarned; + } + + public void addMoneyEarned(double amount) { + this.moneyEarned += amount; + } + + public Teacher getTeacher() { + return teacher; + } + + public void setTeacher(Teacher teacher) { + this.teacher = teacher; + } +} + diff --git a/SchoolManagementSystem.java b/SchoolManagementSystem.java new file mode 100644 index 00000000..df5513f3 --- /dev/null +++ b/SchoolManagementSystem.java @@ -0,0 +1,67 @@ +import java.util.ArrayList; +import java.util.List; +import java.util.Scanner; + +public class SchoolManagementSystem { + private String schoolName; + private List teachers; + private List courses; + private List students; + + public SchoolManagementSystem() { + this.teachers = new ArrayList<>(); + this.courses = new ArrayList<>(); + this.students = new ArrayList<>(); + } + + public void start() { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter school name: "); + schoolName = scanner.nextLine(); + + System.out.print("Enter the number of teachers to create: "); + int numTeachers = Integer.parseInt(scanner.nextLine()); + + for (int i = 0; i < numTeachers; i++) { + System.out.print("Enter teacher name: "); + String teacherName = scanner.nextLine(); + System.out.print("Enter teacher salary: "); + double teacherSalary = Double.parseDouble(scanner.nextLine()); + teachers.add(new Teacher(teacherName, teacherSalary)); + } + + System.out.print("Enter the number of courses to create: "); + int numCourses = Integer.parseInt(scanner.nextLine()); + + for (int i = 0; i < numCourses; i++) { + System.out.print("Enter course name: "); + String courseName = scanner.nextLine(); + System.out.print("Enter course price: "); + double coursePrice = Double.parseDouble(scanner.nextLine()); + courses.add(new Course(courseName, coursePrice)); + } + + System.out.print("Enter the number of students to create: "); + int numStudents = Integer.parseInt(scanner.nextLine()); + + for (int i = 0; i < numStudents; i++) { + System.out.print("Enter student name: "); + String studentName = scanner.nextLine(); + System.out.print("Enter student address: "); + String studentAddress = scanner.nextLine(); + System.out.print("Enter student email: "); + String studentEmail = scanner.nextLine(); + students.add(new Student(studentName, studentAddress, studentEmail)); + } + + // Add commands to handle user interaction here + + scanner.close(); + } + + public static void main(String[] args) { + SchoolManagementSystem sms = new SchoolManagementSystem(); + sms.start(); + } +} \ No newline at end of file diff --git a/Student.java b/Student.java new file mode 100644 index 00000000..df939029 --- /dev/null +++ b/Student.java @@ -0,0 +1,53 @@ +import java.util.UUID; + +public class Student { + private String studentId; + private String name; + private String address; + private String email; + private Course course; + + public Student(String name, String address, String email) { + this.studentId = UUID.randomUUID().toString(); + this.name = name; + this.address = address; + this.email = email; + this.course = null; + } + + public String getStudentId() { + return studentId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Course getCourse() { + return course; + } + + public void setCourse(Course course) { + this.course = course; + } +} diff --git a/Teacher.java b/Teacher.java new file mode 100644 index 00000000..03d49e6d --- /dev/null +++ b/Teacher.java @@ -0,0 +1,33 @@ +import java.util.UUID; + +public class Teacher { + private String teacherId; + private String name; + private double salary; + + public Teacher(String name, double salary) { + this.teacherId = UUID.randomUUID().toString(); + this.name = name; + this.salary = salary; + } + + public String getTeacherId() { + return teacherId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public double getSalary() { + return salary; + } + + public void setSalary(double salary) { + this.salary = salary; + } +} diff --git a/out/production/homework-java-ironschool/.idea/.gitignore b/out/production/homework-java-ironschool/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /dev/null +++ b/out/production/homework-java-ironschool/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/out/production/homework-java-ironschool/.idea/homework-java-ironschool.iml b/out/production/homework-java-ironschool/.idea/homework-java-ironschool.iml new file mode 100644 index 00000000..b107a2dd --- /dev/null +++ b/out/production/homework-java-ironschool/.idea/homework-java-ironschool.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/homework-java-ironschool/.idea/misc.xml b/out/production/homework-java-ironschool/.idea/misc.xml new file mode 100644 index 00000000..e6be3f13 --- /dev/null +++ b/out/production/homework-java-ironschool/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/homework-java-ironschool/.idea/modules.xml b/out/production/homework-java-ironschool/.idea/modules.xml new file mode 100644 index 00000000..7d988043 --- /dev/null +++ b/out/production/homework-java-ironschool/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/homework-java-ironschool/.idea/vcs.xml b/out/production/homework-java-ironschool/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/out/production/homework-java-ironschool/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/homework-java-ironschool/Course.class b/out/production/homework-java-ironschool/Course.class new file mode 100644 index 00000000..80f92dfb Binary files /dev/null and b/out/production/homework-java-ironschool/Course.class differ diff --git a/out/production/homework-java-ironschool/README.md b/out/production/homework-java-ironschool/README.md new file mode 100644 index 00000000..1d3c661a --- /dev/null +++ b/out/production/homework-java-ironschool/README.md @@ -0,0 +1,108 @@ +![logo_ironhack_blue 7](https://user-images.githubusercontent.com/23629340/40541063-a07a0a8a-601a-11e8-91b5-2f13e4e6b441.png) + +# HW | Java IronSchool (Unit 2 homework) + +## Introduction + +For this homework, you will be building a School Management System, that will help manage students, teachers and courses with some basic functionalities. + +## Instructions + +Let's walk through the details of the homework: + +### Classes + +Three main classes are necessary to complete this homework: **Teacher**, **Student** and **Course**. + +
+ +**Teacher class** + +This class will have: + +- Variable called `teacherId` of data type `string`, auto-generated (Private member) +- Variable called `name` of data type `string` (Private member) +- Variable called `salary` of data type `double`, representing the salary of the teacher (Private member) +- A parameterized constructor that takes `name` and `salary` +- Public Getter functions to access these variables +- Public Setter functions to change these variables +- Optional attributes are accepted if needed based on the code structure + +
+ +**Course class** + +This class will have: + +- Variable called `courseId` of data type `string`, auto-generated (Private member) +- Variable called `name` of data type `string` (Private member) +- Variable called `price` of data type `double`, representing the price of this course (Private member) +- Variable called `money_earned` of data type `double`, representing the total money earned by this course (Private member) +- Nullable variable called `teacher` of data type `Teacher` (Private member) +- A parameterized constructor that takes `name` and `price` +- Public Getter functions to access these variables +- Public Setter functions to change these variables +- Optional attributes are accepted if needed based on the code structure + +
+ +**Student class** + +This class will have: + +- Variable called `studentId` of data type `string`, auto-generated (Private member) +- Variable called `name` of data type `string` (Private member) +- Variable called `address` of data type `string` (Private member) +- Variable called `email` of data type `string` (Private member) +- Nullable variable called `course` of data type `Course`, representing the course this student is enrolled into (Private member) +- A parameterized constructor that takes `name`, `address` and `email` +- Public Getter functions to access these variables +- Public Setter functions to change these variables +- Optional attributes are accepted if needed based on the code structure + +## How the application works + +1. The application starts by asking the user for a name for the school +2. Next, the user is asked for a number of how many teachers should be created +3. Next, the user is prompted to enter the details of each teacher (based on the number chosen above) +4. Next, the user is asked for the number of courses to be created (Do not specify the teacher yet, there is a command for it) +5. Next, the user is prompted to enter details of each course based on the number chosen above +6. Next, the user is asked for the number of students to be created (Do not specify the course yet, there is a command for it) +7. Next, the user is prompted to enter details of each student based on the number chosen above +8. Next, the user is now prompted to enter any command of the list below to execute a specified action in the system. + +The IDs should be automatically generated. + +## Commands + +- **ENROLL** **[STUDENT_ID] [COURSE_ID]**: This command will help enroll the student specified in the corresponding course. While also updating the `money_earned` of that course based on its price +- **ASSIGN** **[TEACHER_ID] [COURSE_ID]**: This command will help assign the teacher specified to the corresponding course +- **SHOW COURSES**: This command will display a list of all courses +- **LOOKUP COURSE** **[COURSE_ID]**: This command will display the full details of the specified course +- **SHOW STUDENTS**: This command will display a list of all students +- **LOOKUP STUDENT** **[STUDENT_ID]**: This command will display the full details of the specified student +- **SHOW TEACHERS**: This command will display a list of all teachers +- **LOOKUP TEACHER** **[TEACHER_ID]**: This command will display the full details of the specified teacher +- **SHOW PROFIT**: This command will calculate **(The total money earned from all courses)** - **(The sum of all the teachers' salaries)** and return the result + +## Requirements + +For this project you must accomplish all of the following: + +1. Navigate through a text-based menu using Standard Input and Output. +2. Create unit tests for every method other than basic getters, setters and constructors (getters and setters with logic do require unit tests). +3. Handle all exceptions gracefully (incorrect input should not crash the program). +4. Create Teachers, Courses and Students specifying their full details. +5. Handle receiving commands in the Standard Input that corresponds to actual actions in the system. + +### Bonus + +1. Add more commands that can help display more information such as (**SHOW STUDENTS** **[COURSE_ID]**, **SHOW MONEY EARNED**, **SHOW MONEY SPENT**, etc.) + +## Important Notes + +- Everyone in the squad should contribute equally to the project in time and lines of code written. +- All code must be reviewed before it is merged into the `master` branch. +- All squad members must participate in code review. +- Every repository should have a README file with clear instructions, demo files, or any documentation needed so other teams don't have problems with the review. +- This is intended to be a challenging assignment. You will have to rely heavily on your teammates and independent research. Learning independently is a hallmark of a good developer and our job is to turn you into good developers. This process may be frustrating but you will learn a ton! \ No newline at end of file diff --git a/out/production/homework-java-ironschool/SchoolManagementSystem.class b/out/production/homework-java-ironschool/SchoolManagementSystem.class new file mode 100644 index 00000000..c9f28c62 Binary files /dev/null and b/out/production/homework-java-ironschool/SchoolManagementSystem.class differ diff --git a/out/production/homework-java-ironschool/Student.class b/out/production/homework-java-ironschool/Student.class new file mode 100644 index 00000000..c5b55a72 Binary files /dev/null and b/out/production/homework-java-ironschool/Student.class differ diff --git a/out/production/homework-java-ironschool/Teacher.class b/out/production/homework-java-ironschool/Teacher.class new file mode 100644 index 00000000..58181629 Binary files /dev/null and b/out/production/homework-java-ironschool/Teacher.class differ