├── Collections
├── README.md
└── src
│ └── com
│ └── generation
│ ├── Course.java
│ ├── CourseService.java
│ ├── Main.java
│ └── Student.java
├── Control Flow
└── README.md
├── Final Project
├── .idea
│ ├── .gitignore
│ ├── misc.xml
│ ├── modules.xml
│ └── vcs.xml
├── JAVA-13 - Final Project.iml
├── README.md
├── out
│ └── production
│ │ └── JAVA-13 - Final Project
│ │ └── com
│ │ └── generation
│ │ ├── Main.class
│ │ ├── model
│ │ ├── Course.class
│ │ ├── Evaluation.class
│ │ ├── Instructor.class
│ │ ├── Module.class
│ │ ├── Person.class
│ │ └── Student.class
│ │ ├── service
│ │ ├── CourseService.class
│ │ └── StudentService.class
│ │ └── utils
│ │ └── PrinterHelper.class
└── src
│ └── com
│ └── generation
│ ├── Main.java
│ ├── model
│ ├── Course.java
│ ├── Evaluation.java
│ ├── Instructor.java
│ ├── Module.java
│ ├── Person.java
│ └── Student.java
│ ├── service
│ ├── CourseService.java
│ └── StudentService.java
│ └── utils
│ └── PrinterHelper.java
├── Functions
├── README.md
└── src
│ └── com
│ └── generation
│ └── Main.java
├── Java IDE IntelliJ Idea
├── LICENSE
├── README.md
└── src
│ └── com
│ └── generation
│ └── java
│ ├── GenerationPrinter.java
│ └── Main.java
├── Logic Operators
└── README.md
├── Loops
└── README.md
├── Object Oriented Programming - Advanced
├── README.md
└── src
│ └── com
│ └── generation
│ ├── Course.java
│ ├── CourseNotFoundException.java
│ ├── Main.java
│ ├── Student.java
│ ├── StudentNotFoundException.java
│ └── StudentService.java
├── Object Oriented Programming - Fundamentals
├── README.md
└── Theory session
│ ├── 1 -Myclass.java
│ ├── 1-Myclass-answer.java
│ └── 2-Shoe-answer.java
├── Polymorphism and Inheritance
├── README.md
└── src
│ └── com
│ └── generation
│ ├── Employee.java
│ ├── Main.java
│ ├── SalesManager.java
│ └── SalesRep.java
├── README.md
├── Unit Testing with JUnit
├── README.md
└── src
│ └── calculator
│ ├── model
│ ├── Calculator.java
│ └── drive
│ │ ├── Driver.java
│ │ ├── DriversManager.java
│ │ ├── DriversManagerTest.java
│ │ └── Passenger.java
│ ├── tdd
│ ├── CalculatorTDD.java
│ └── CalculatorTDDTest.java
│ └── test
│ └── CalculatorTest.java
└── Variables, Data Types and Operators
└── README.md
/Collections/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Collections
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Exploring the Course Services Project
11 |
12 | 1. Download the src folder and import the project into IntelliJ Idea
13 | 2. Run the main method and observe what happens
14 | 3. Read the code on the *Main* class and try to understand why is not working
15 | 4. Go to the *Student*, *Course* and *CourseService* class and read the code trying to undertand the functionality of each class(don't worry if you don't undertand 100% you will get there if you persist!)
16 | 5. Open the *Student* class and implement the following methods:
17 |
18 | ```java
19 | public void enroll(Course course){
20 | //TODO implement
21 | }
22 |
23 | public void unEnroll(Course course){
24 | //TODO implement
25 | }
26 |
27 | public int totalEnrolledCourses(){
28 | //TODO implement
29 | return 0;
30 | }
31 | ```
32 |
33 | ## Part 2: Implementing the Course Services Project
34 | 1. Find a classmate to work for this part (Pair programming time!)
35 | 2. Discuss with your pair programming buddy what you both understood from the project.
36 | 3. Implement the following methods of the *CourseService* class:
37 |
38 | ```java
39 | public void enrollStudent(String studentId, String courseId){
40 | //TODO implement so it adds the given course form the student
41 | }
42 |
43 | public void unEnrollStudent(String studentId, String courseId){
44 | //TODO implement so it removes the given course form the student
45 | }
46 |
47 | public void displayCourseInformation(String courseId){
48 | //TODO implement so it shows the course name, id and credits
49 | }
50 |
51 | public void displayStudentInformation(String studentId){
52 | //TODO implement so it shows the student name, id and list of enrolled courses
53 | }
54 | ```
55 | 4. Run the main method and verify that your implementation works.
56 |
57 | ## Challenge yourself
58 |
59 | Implement a function in the *CourseService* class that calculates the total credits that a student has.
60 |
61 |
--------------------------------------------------------------------------------
/Collections/src/com/generation/Course.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Course
4 | {
5 |
6 | String name;
7 |
8 | String id;
9 |
10 | int credits;
11 |
12 | public Course( String name, String id, int credits )
13 | {
14 | this.name = name;
15 | this.id = id;
16 | this.credits = credits;
17 | }
18 |
19 | @Override
20 | public String toString()
21 | {
22 | return "Course{" + "name='" + name + '\'' + ", id='" + id + '\'' + ", credits=" + credits + '}';
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Collections/src/com/generation/CourseService.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import java.util.HashMap;
4 |
5 | public class CourseService
6 | {
7 | HashMap students = new HashMap<>();
8 |
9 | HashMap courses = new HashMap<>();
10 |
11 |
12 | public CourseService()
13 | {
14 | students.put( "120120", new Student( "Santiago", "120120" ) );
15 | students.put( "884545", new Student( "Kate", "884545" ) );
16 | students.put( "458787", new Student( "Alejandra", "458787" ) );
17 | students.put( "135464", new Student( "Maria", "135464" ) );
18 | students.put( "778979", new Student( "Peter", "778979" ) );
19 |
20 | courses.put( "math_01", new Course( "Mathematics 1", "math_01", 8 ) );
21 | courses.put( "biol_01", new Course( "Biology 1", "biol_01", 8 ) );
22 | courses.put( "phys_01", new Course( "Physics 1", "phys_01", 8 ) );
23 | courses.put( "art_01", new Course( "Arts 1", "art_01", 8 ) );
24 | courses.put( "chem_01", new Course( "Chemistry 1", "chem_01", 8 ) );
25 | courses.put( "sport_01", new Course( "Sports 1", "sport_01", 8 ) );
26 | }
27 |
28 | public void enrollStudent(String studentId, String courseId){
29 | //TODO implement so it adds the given course form the student
30 | }
31 |
32 | public void unEnrollStudent(String studentId, String courseId){
33 | //TODO implement so it removes the given course form the student
34 | }
35 |
36 | public void displayCourseInformation(String courseId){
37 | //TODO implement so it shows the course name, id and credits
38 | }
39 |
40 | public void displayStudentInformation(String studentId){
41 | //TODO implement so it shows the student name, id and list of enrolled courses
42 | }
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Collections/src/com/generation/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Main
4 | {
5 | public static void main( String[] args )
6 | {
7 | CourseService courseService = new CourseService();
8 |
9 | String courseId = "math_01";
10 | String studentId = "120120";
11 | courseService.displayCourseInformation( courseId );
12 | courseService.displayStudentInformation( studentId);
13 |
14 | courseService.enrollStudent( studentId, courseId );
15 | courseService.displayStudentInformation( studentId);
16 |
17 | courseService.unEnrollStudent( studentId, courseId );
18 | courseService.displayStudentInformation( studentId);
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/Collections/src/com/generation/Student.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class Student
7 | {
8 | String name;
9 |
10 | String id;
11 |
12 | List enrolledCourses = new ArrayList<>( );
13 |
14 |
15 | public Student( String name, String id )
16 | {
17 | this.name = name;
18 | this.id = id;
19 | }
20 |
21 | public String getName()
22 | {
23 | return name;
24 | }
25 |
26 | public void setName( String name )
27 | {
28 | this.name = name;
29 | }
30 |
31 | public String getId()
32 | {
33 | return id;
34 | }
35 |
36 | public void setId( String id )
37 | {
38 | this.id = id;
39 | }
40 |
41 | public void enroll(Course course){
42 | enrolledCourses.add( course );
43 | }
44 |
45 | public void unEnroll(Course course){
46 | enrolledCourses.remove( course );
47 | }
48 |
49 | public int totalEnrolledCourses(){
50 | //TODO implement
51 | return 0;
52 | }
53 |
54 | public List getEnrolledCourses()
55 | {
56 | return enrolledCourses;
57 | }
58 |
59 | @Override
60 | public String toString()
61 | {
62 | return "Student{" + "name='" + name + '\'' + ", id='" + id + '\'' + ", enrolledCourses=" + enrolledCourses
63 | + '}';
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Control Flow/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Control Flow
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Commission Calculator
11 | 1. Using IntelliJ, write a Java app that takes numerical input from a user
12 | 2. The app should calculate commission based on this chart used by the retail store.
13 |
14 | | Sales Range | Commission
15 | | ------------- |:-------------:|
16 | | above 10000$ | 30% |
17 | | 5001 - 9999$ | 20% |
18 | | 1001 - 4999$ | 10% |
19 | | below 1000$ | N/A |
20 |
21 | 3. **Example:** if a user enters 7677 as their sales figure, it should calculate commission at 20%.
22 |
23 |
24 | ## Part 2: Movie Discounts
25 | 1. A movie cinema does price discounting depending on a customer's age.
26 | 2. The app prompts a user to enter their age on the IntelliJ console after which it checks whether the user meets the discount conditions.
27 |
28 | | Age range | Ticket Price
29 | | ------------- |:-------------:|
30 | | Normal ticket | 7 Euros |
31 | | Below 5 | 60% Discount |
32 | | Over 60 | 55% Discount |
33 |
34 | 3. Write the app so that the conditions above are met and the correct ticket price is returned.
35 |
36 | ## Extra features
37 | If done with the first part of the exercise with time to spare add the following feature.
38 | 1. Have the app prompt normal ticket buyers for the number of tickets they wish to buy.
39 | 2. For every two or more tickets sold, give a 30% discount.
40 |
--------------------------------------------------------------------------------
/Final Project/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /workspace.xml
--------------------------------------------------------------------------------
/Final Project/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Final Project/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Final Project/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Final Project/JAVA-13 - Final Project.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Final Project/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Java Programming Fundamentals - Assessment
5 |
6 |
7 |
8 | It's time to see how much you learned about Java and Object Oriented Programming.
9 |
10 | ## Part 1: Understanding the StudentGen project
11 | 1. Download the source code and import the project using IntelliJ Idea or any other IDE you prefer.
12 | 2. Understand the project stucture:
13 | * Packages
14 | * Classes
15 | * Functionality
16 | 3. Run and test the project to get a deeper undertanding of how it works (remember the persistence mindset!).
17 |
18 | ## Part 2: Implementing the Student and StudentService missing features
19 | 1. Open the *Student* class (`src/com/generation/model/Student.java`) and implement the following methods:
20 |
21 | ```java
22 | public void enrollToCourse( Course course )
23 | {
24 | //TODO implement this method
25 | }
26 |
27 | public boolean isCourseApproved( String courseCode )
28 | {
29 | //TODO implement this method
30 | return false;
31 | }
32 |
33 | public boolean isAttendingCourse( String courseCode )
34 | {
35 | //TODO implement this method
36 | return false;
37 | }
38 | @Override
39 | public List getApprovedCourses()
40 | {
41 | //TODO implement this method
42 | return null;
43 | }
44 | ```
45 |
46 | 2. Open the *StudentService* class (`src/com/generation/service/StudentService.java`) and implement the following methods:
47 |
48 | ```java
49 | public boolean isSubscribed( String studentId )
50 | {
51 | //TODO implement this method
52 | return false;
53 | }
54 |
55 | public void showSummary()
56 | {
57 | //TODO implement
58 | }
59 | ```
60 |
61 | Hint: To show the summary use `System.out.println()` to print out to the console.
62 |
63 | ## Part 3: Implementing the missing main method features
64 |
65 | 1. Implement the method to *gradeStudent( StudentService studentService, Scanner scanner )* in `src/com/generation/Main.java ` to have a fully functional program.
66 |
67 | 2. Test the program to verify it works as expected:
68 | * Create a new student.
69 | * Enrroll the student to few courses.
70 | * Grade the student.
71 | * Show the students and courses summary and verify that data is correct.
72 |
73 |
74 | ## Part 4: Handling exceptions
75 | 1. Register a new user providing a wrong date format.
76 | 2. Modify the createStudentMenu so it handles correctly the exception when a wrong date format is inserted by the user.
77 | 3. Catch the exception and show a proper message to the user.
78 |
79 | ## Part 5: Writing Unit Tests
80 | 1. Write 2 Unit tests for the class *StudentService*
81 | 2. Write 2 Unit tests for the class *CourseService*
82 |
83 |
84 | ## Challenge Yourself
85 | 1. Implement a way to store grades for each course a student is taking. There should be a way to update/set the score.
86 | Afterwards, fill in the `public List findPassedCourses( Course course )` method in Student.java
87 | 2. Implement an additional feature in the menu options that will display the average grade of all the students suscribed to a given course.
88 |
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/Main.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Course.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Evaluation.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Instructor.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Module.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Person.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/model/Student.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/CourseService.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/service/StudentService.class
--------------------------------------------------------------------------------
/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/generation-org/JAVA/e987226e674f5051769c17c941032fcd9f6700e2/Final Project/out/production/JAVA-13 - Final Project/com/generation/utils/PrinterHelper.class
--------------------------------------------------------------------------------
/Final Project/src/com/generation/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import com.generation.model.Course;
4 | import com.generation.model.Student;
5 | import com.generation.service.CourseService;
6 | import com.generation.service.StudentService;
7 | import com.generation.utils.PrinterHelper;
8 |
9 | import java.text.ParseException;
10 | import java.util.Scanner;
11 |
12 | public class Main
13 | {
14 |
15 | public static void main( String[] args )
16 | throws ParseException
17 | {
18 | StudentService studentService = new StudentService();
19 | CourseService courseService = new CourseService();
20 | Scanner scanner = new Scanner( System.in );
21 | int option = 0;
22 | do
23 | {
24 | PrinterHelper.showMainMenu();
25 | option = scanner.nextInt();
26 | switch ( option )
27 | {
28 | case 1:
29 | registerStudent( studentService, scanner );
30 | break;
31 | case 2:
32 | findStudent( studentService, scanner );
33 | break;
34 | case 3:
35 | gradeStudent( studentService, scanner );
36 | break;
37 | case 4:
38 | enrollStudentToCourse( studentService, courseService, scanner );
39 | break;
40 | case 5:
41 | showStudentsSummary( studentService, scanner );
42 | break;
43 | case 6:
44 | showCoursesSummary( courseService, scanner );
45 | break;
46 | }
47 | }
48 | while ( option != 7 );
49 | }
50 |
51 | private static void enrollStudentToCourse( StudentService studentService, CourseService courseService,
52 | Scanner scanner )
53 | {
54 | System.out.println( "Insert student ID" );
55 | String studentId = scanner.next();
56 | Student student = studentService.findStudent( studentId );
57 | if ( student == null )
58 | {
59 | System.out.println( "Invalid Student ID" );
60 | return;
61 | }
62 | System.out.println( student );
63 | System.out.println( "Insert course ID" );
64 | String courseId = scanner.next();
65 | Course course = courseService.getCourse( courseId );
66 | if ( course == null )
67 | {
68 | System.out.println( "Invalid Course ID" );
69 | return;
70 | }
71 | System.out.println( course );
72 | courseService.enrollStudent( courseId, student );
73 | studentService.enrollToCourse( studentId, course );
74 | System.out.println( "Student with ID: " + studentId + " enrolled successfully to " + courseId );
75 |
76 | }
77 |
78 | private static void showCoursesSummary( CourseService courseService, Scanner scanner )
79 | {
80 | courseService.showSummary();
81 | }
82 |
83 | private static void showStudentsSummary( StudentService studentService, Scanner scanner )
84 | {
85 | studentService.showSummary();
86 | }
87 |
88 | private static void gradeStudent( StudentService studentService, Scanner scanner )
89 | {
90 |
91 | }
92 |
93 | private static void findStudent( StudentService studentService, Scanner scanner )
94 | {
95 | System.out.println( "Enter student ID: " );
96 | String studentId = scanner.next();
97 | Student student = studentService.findStudent( studentId );
98 | if ( student != null )
99 | {
100 | System.out.println( "Student Found: " );
101 | System.out.println( student );
102 | }
103 | else
104 | {
105 | System.out.println( "Student with Id = " + studentId + " not found" );
106 | }
107 | }
108 |
109 | private static void registerStudent( StudentService studentService, Scanner scanner )
110 | throws ParseException
111 | {
112 | Student student = PrinterHelper.createStudentMenu( scanner );
113 | studentService.subscribeStudent( student );
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Course.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | public class Course
4 | {
5 | private final String code;
6 |
7 | private final String name;
8 |
9 | private final int credits;
10 |
11 | private final Module module;
12 |
13 |
14 | public Course( String code, String name, int credits, Module module )
15 | {
16 | this.code = code;
17 | this.name = name;
18 | this.credits = credits;
19 | this.module = module;
20 | }
21 |
22 | public String getCode()
23 | {
24 | return code;
25 | }
26 |
27 | public String getName()
28 | {
29 | return name;
30 | }
31 |
32 | public int getCredits()
33 | {
34 | return credits;
35 | }
36 |
37 | public Module getModule()
38 | {
39 | return module;
40 | }
41 |
42 | @Override
43 | public String toString()
44 | {
45 | return "Course{" + "code='" + code + '\'' + ", name='" + name + '\'' + ", credits=" + credits + ", module="
46 | + module + '}';
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Evaluation.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | import java.util.List;
4 |
5 | public interface Evaluation
6 | {
7 | double getAverage();
8 |
9 | List getApprovedCourses();
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Instructor.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | public class Instructor
8 | extends Person
9 | {
10 |
11 | private int experienceMonths;
12 |
13 | private final List teachingCourses = new ArrayList<>();
14 |
15 | protected Instructor( String id, String name, String email, Date birthDate )
16 | {
17 | super( id, name, email, birthDate );
18 | }
19 |
20 | public int getExperienceMonths()
21 | {
22 | return experienceMonths;
23 | }
24 |
25 | public void setExperienceMonths( int experienceMonths )
26 | {
27 | this.experienceMonths = experienceMonths;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Module.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class Module
7 | {
8 | private final String code;
9 |
10 | private final String name;
11 |
12 | private final String description;
13 |
14 | private final Map prerequisites = new HashMap<>();
15 |
16 | public Module( String code, String name, String description )
17 | {
18 | this.code = code;
19 | this.name = name;
20 | this.description = description;
21 | }
22 |
23 | public void addPrerequisite( Module module )
24 | {
25 | prerequisites.put( module.code, module );
26 | }
27 |
28 |
29 | public String getCode()
30 | {
31 | return code;
32 | }
33 |
34 | public String getName()
35 | {
36 | return name;
37 | }
38 |
39 | public String getDescription()
40 | {
41 | return description;
42 | }
43 |
44 | public Map getPrerequisites()
45 | {
46 | return prerequisites;
47 | }
48 |
49 | @Override
50 | public String toString()
51 | {
52 | return "Module{" + "name='" + name + '\'' + '}';
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Person.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | import java.util.Date;
4 |
5 | abstract public class Person
6 | {
7 | private final String id;
8 |
9 | private final String name;
10 |
11 | private final String email;
12 |
13 | private final Date birthDate;
14 |
15 | protected Person( String id, String name, String email, Date birthDate )
16 | {
17 | this.id = id;
18 | this.name = name;
19 | this.email = email;
20 | this.birthDate = birthDate;
21 | }
22 |
23 | public String getId()
24 | {
25 | return id;
26 | }
27 |
28 | public String getName()
29 | {
30 | return name;
31 | }
32 |
33 | public String getEmail()
34 | {
35 | return email;
36 | }
37 |
38 | public Date getBirthDate()
39 | {
40 | return birthDate;
41 | }
42 |
43 | @Override
44 | public String toString()
45 | {
46 | return id + '\'' + ", name='" + name + '\'' + ", email='" + email + '\'' + ", birthDate=" + birthDate;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/model/Student.java:
--------------------------------------------------------------------------------
1 | package com.generation.model;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | public class Student
10 | extends Person
11 | implements Evaluation
12 | {
13 | private double average;
14 |
15 | private final List courses = new ArrayList<>();
16 |
17 | private final Map approvedCourses = new HashMap<>();
18 |
19 | public Student( String id, String name, String email, Date birthDate )
20 | {
21 | super( id, name, email, birthDate );
22 | }
23 |
24 | public void enrollToCourse( Course course )
25 | {
26 | //TODO implement this method
27 | }
28 |
29 | public void registerApprovedCourse( Course course )
30 | {
31 | approvedCourses.put( course.getCode(), course );
32 | }
33 |
34 | public boolean isCourseApproved( String courseCode )
35 | {
36 | //TODO implement this method
37 | return false;
38 | }
39 |
40 | // CHALLENGE IMPLEMENTATION: Read README.md to find instructions on how to solve.
41 | public List findPassedCourses( Course course )
42 | {
43 | //TODO implement this method
44 | return null;
45 | }
46 |
47 | public boolean isAttendingCourse( String courseCode )
48 | {
49 | //TODO implement this method
50 | return false;
51 | }
52 |
53 | @Override
54 | public double getAverage()
55 | {
56 | return average;
57 | }
58 |
59 | @Override
60 | public List getApprovedCourses()
61 | {
62 | //TODO implement this method
63 | return null;
64 | }
65 |
66 | @Override
67 | public String toString()
68 | {
69 | return "Student {" + super.toString() + "}";
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/service/CourseService.java:
--------------------------------------------------------------------------------
1 | package com.generation.service;
2 |
3 | import com.generation.model.Course;
4 | import com.generation.model.Module;
5 | import com.generation.model.Student;
6 |
7 | import java.util.ArrayList;
8 | import java.util.HashMap;
9 | import java.util.List;
10 | import java.util.Map;
11 |
12 | public class CourseService
13 | {
14 | private final Map courses = new HashMap<>();
15 |
16 | private final Map> enrolledStudents = new HashMap<>();
17 |
18 | public CourseService()
19 | {
20 | Module module = new Module( "INTRO-CS", "Introduction to Computer Science",
21 | "Introductory module for the generation technical programs" );
22 | registerCourse( new Course( "INTRO-CS-1", "Introduction to Computer Science", 9, module ) );
23 | registerCourse( new Course( "INTRO-CS-2", "Introduction to Algorithms", 9, module ) );
24 | registerCourse( new Course( "INTRO-CS-3", "Algorithm Design and Problem Solving - Introduction ", 9, module ) );
25 | registerCourse( new Course( "INTRO-CS-4", "Algorithm Design and Problem Solving - Advanced", 9, module ) );
26 | registerCourse( new Course( "INTRO-CS-5", "Terminal Fundamentals", 9, module ) );
27 | registerCourse( new Course( "INTRO-CS-6", "Source Control Using Git and Github", 9, module ) );
28 | registerCourse( new Course( "INTRO-CS-7", "Agile Software Development with SCRUM", 9, module ) );
29 |
30 | Module moduleWebFundamentals = new Module( "INTRO-WEB", "Web Development Fundamentals",
31 | "Introduction to fundamentals of web development" );
32 | registerCourse( new Course( "INTRO-WEB-1", "Introduction to Web Applications", 9, moduleWebFundamentals ) );
33 | registerCourse( new Course( "INTRO-WEB-2", "Introduction to HTML", 9, moduleWebFundamentals ) );
34 | registerCourse( new Course( "INTRO-WEB-3", "Introduction to CSS", 9, moduleWebFundamentals ) );
35 | registerCourse( new Course( "INTRO-WEB-4", "Advanced HTML", 9, moduleWebFundamentals ) );
36 | registerCourse( new Course( "INTRO-WEB-5", "Advanced CSS", 9, moduleWebFundamentals ) );
37 | registerCourse( new Course( "INTRO-WEB-6", "Introduction to Bootstrap Framework", 9, moduleWebFundamentals ) );
38 | registerCourse(
39 | new Course( "INTRO-WEB-7", "Introduction to JavaScript for Web Development", 9, moduleWebFundamentals ) );
40 |
41 | }
42 |
43 | public void registerCourse( Course course )
44 | {
45 | courses.put( course.getCode(), course );
46 | }
47 |
48 | public Course getCourse( String code )
49 | {
50 | if ( courses.containsKey( code ) )
51 | {
52 | return courses.get( code );
53 | }
54 | return null;
55 | }
56 |
57 | public void enrollStudent( String courseId, Student student )
58 | {
59 | if ( !enrolledStudents.containsKey( courseId ) )
60 | {
61 | enrolledStudents.put( courseId, new ArrayList<>() );
62 | }
63 | enrolledStudents.get( courseId ).add( student );
64 | }
65 |
66 | public void showEnrolledStudents( String courseId )
67 | {
68 | if ( enrolledStudents.containsKey( courseId ) )
69 | {
70 | List students = enrolledStudents.get( courseId );
71 | for ( Student student : students )
72 | {
73 | System.out.println( student );
74 | }
75 | }
76 | }
77 |
78 |
79 | public void showSummary()
80 | {
81 | System.out.println( "Available Courses:" );
82 | for ( String key : courses.keySet() )
83 | {
84 | Course course = courses.get( key );
85 | System.out.println( course );
86 | }
87 | System.out.println( "Enrolled Students" );
88 | for ( String key : enrolledStudents.keySet() )
89 | {
90 | List students = enrolledStudents.get( key );
91 | System.out.println( "Students on Course " + key + ": " );
92 | for ( Student student : students )
93 | {
94 | System.out.println( student );
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/service/StudentService.java:
--------------------------------------------------------------------------------
1 | package com.generation.service;
2 |
3 | import com.generation.model.Course;
4 | import com.generation.model.Student;
5 |
6 | import java.util.HashMap;
7 | import java.util.Map;
8 |
9 | public class StudentService
10 | {
11 | private final Map students = new HashMap<>();
12 |
13 | public void subscribeStudent( Student student )
14 | {
15 | students.put( student.getId(), student );
16 | }
17 |
18 | public Student findStudent( String studentId )
19 | {
20 | if ( students.containsKey( studentId ) )
21 | {
22 | return students.get( studentId );
23 | }
24 | return null;
25 | }
26 |
27 | public boolean isSubscribed( String studentId )
28 | {
29 | //TODO implement this method
30 | return false;
31 | }
32 |
33 | public void showSummary()
34 | {
35 | //TODO implement
36 | }
37 |
38 | public void enrollToCourse( String studentId, Course course )
39 | {
40 | if ( students.containsKey( studentId ) )
41 | {
42 | students.get( studentId ).enrollToCourse( course );
43 | }
44 | }
45 |
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/Final Project/src/com/generation/utils/PrinterHelper.java:
--------------------------------------------------------------------------------
1 | package com.generation.utils;
2 |
3 | import com.generation.model.Student;
4 |
5 | import java.text.DateFormat;
6 | import java.text.ParseException;
7 | import java.text.SimpleDateFormat;
8 | import java.util.Date;
9 | import java.util.Scanner;
10 |
11 | public class PrinterHelper
12 | {
13 |
14 | public static void showMainMenu(){
15 | System.out.println( "|-------------------------------|" );
16 | System.out.println( "| Welcome to StudentGen |" );
17 | System.out.println( "|-------------------------------|" );
18 | System.out.println( "| Select 1 option: |" );
19 | System.out.println( "| . 1 Register Student |" );
20 | System.out.println( "| . 2 Find Student |" );
21 | System.out.println( "| . 3 Grade Student |" );
22 | System.out.println( "| . 4 Enroll Student to Course |" );
23 | System.out.println( "| . 5 Show Students Summary |" );
24 | System.out.println( "| . 6 Show Courses Summary |" );
25 | System.out.println( "| . 7 Exit |" );
26 | System.out.println( "|-------------------------------|" );
27 | }
28 |
29 | public static Student createStudentMenu( Scanner scanner )
30 | throws ParseException
31 | {
32 | System.out.println( "|-------------------------------------|" );
33 | System.out.println( "| . 1 Register Student |" );
34 | System.out.println( "|-------------------------------------|" );
35 | System.out.println( "| Enter student name: |" );
36 | String name = scanner.next();
37 | System.out.println( "| Enter student ID: |" );
38 | String id = scanner.next();
39 | System.out.println( "| Enter student email: |" );
40 | String email = scanner.next();
41 | System.out.println( "| Enter student birth date(mm/dd/yyyy)|" );
42 | DateFormat formatter = new SimpleDateFormat( "mm/dd/yyyy");
43 | //TODO validate date format and catch exception to avoid crash
44 | Date birthDate = formatter.parse( scanner.next());
45 | System.out.println( "|-------------------------------------|" );
46 | Student student = new Student( id, name, email, birthDate );
47 | System.out.println( "Student Successfully Registered! " );
48 | System.out.println(student);
49 | return student;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/Functions/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Functions
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1:
11 |
12 | 1. Download the project and import it into IntelliJ Idea
13 | 2. Implement the following functions:
14 |
15 | ```java
16 | private static void printNameLength( String name )
17 | {
18 | //TODO implement this code
19 | }
20 |
21 | private static void printNameCharacters( String name )
22 | {
23 | //TODO implement this code
24 | }
25 |
26 | ```
27 | 3. Test your code with 5 different names and verify that the behaviour is correct.
28 | 4. Modify your code to also capture from the user the last name.
29 | 5. Implement an additional function that prints the FUll name of the person.
30 |
31 | ## Part 2:
32 |
33 | Create a new Java class that will have the following functionality:
34 |
35 | 1. Name should be CalculatorBrain
36 | 2. Implement a function for each aritmetic operation
37 | * Addition
38 | * Subtraction
39 | * Multiplication
40 | * Division
41 | 3. Add some code to the *main* method to invoke the aritmetic functions defined and verify it works as expected.
42 |
43 | ## Challenge yourself
44 | Add some more functionality to your *CalculatorBrain*:
45 | * Square Root
46 | * Power Of
47 |
--------------------------------------------------------------------------------
/Functions/src/com/generation/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import java.util.Scanner;
4 |
5 | public class Main
6 | {
7 | public static void main( String[] args )
8 | {
9 | Scanner console = new Scanner( System.in );
10 | System.out.println( "Enter your name: " );
11 | String name = console.next();
12 | printNameCharacters( name );
13 | printNameLength( name );
14 | console.close();
15 | }
16 |
17 | private static void printNameLength( String name )
18 | {
19 | //TODO implement this code
20 | }
21 |
22 | private static void printNameCharacters( String name )
23 | {
24 | //TODO implement this code
25 | }
26 |
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/Java IDE IntelliJ Idea/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Java IDE IntelliJ Idea/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Java IDE - IntelliJ Idea
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Creating my First Java Project on IntelliJ Idea
11 | 1. Open the IntelliJ Idea App and follow the instructions to create a new Java Project.
12 | 2. Edit the Main class so it prints "Hello Wolrd!" message:
13 |
14 | ```java
15 | package com.generation.java;
16 |
17 | public class Main {
18 |
19 | public static void main(String[] args) {
20 | System.out.println( "Hello World!" );
21 | }
22 | }
23 |
24 | ```
25 | 3. Run your application using the run button next to the *main* method.
26 | 4. Run your application using the run button next to the *main* class declaration.
27 | 5. Add a breakpoint to line 6 of your application *System.out.println( "Hello World!" );*
28 | 6. Add 3 or 4 lines more to your code with the same instruction *System.out.println()* but a different message.
29 | 6. Run your application on Debug mode and verify how the following buttons of the debug view work:
30 | * Step Over
31 | * Step Into
32 | * Step Out
33 | * Resume Program
34 | 7. Add the following code to your application *main* method:
35 | ```java
36 | package com.generation.java;
37 |
38 | public class Main {
39 | public static void main(String[] args) {
40 | String test = "Hello";
41 | test+= " World!";
42 | test+= " Welcome to Generation";
43 | }
44 | }
45 | ```
46 | 8. Add a breakpoint to first line *String test = "Hello";*
47 | 9. Run your application again on Debug mode and observe how the variable test changes.
48 |
49 | ## Part 2: Importing an existing project into IntelliJ Idea
50 | 1. Download this repository
51 | 2. Exctract the downloaded files
52 | 3. Click on the *File* menu of the IDE and select the option open project and select the folder of the exctracted files
53 | 4. Browse the project files and try to understand what the programm does.
54 | 5. Change the name passed on the main method to your name and run the program to verify it works.
55 |
--------------------------------------------------------------------------------
/Java IDE IntelliJ Idea/src/com/generation/java/GenerationPrinter.java:
--------------------------------------------------------------------------------
1 | package com.generation.java;
2 |
3 | public class GenerationPrinter
4 | {
5 | public void sayHello(String name){
6 | System.out.println( "Hello "+name );
7 | }
8 |
9 | public void sayGoodBye(String name){
10 | System.out.println( "Good bye "+name );
11 | }
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/Java IDE IntelliJ Idea/src/com/generation/java/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation.java;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | GenerationPrinter generationPrinter = new GenerationPrinter();
7 | generationPrinter.sayHello( "Santiago" );
8 | generationPrinter.sayGoodBye( "Santiago" );
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Logic Operators/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Logic Operators
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Class Grader
11 | 1. Open IntelliJ Idea App and create a project called **ClassGrader**
12 | 2. Write a program where a user enters the grade of a student and the program returns a grade based on the following conditions
13 | - **Failed** if they scored 3 or less
14 | - **Insufficient** if they scored > 3 but less than 5. (5 included)
15 | - **Good** if they scored > 5 but less than 8. (8 included)
16 | - **Excellent Grade** if they scored 10.
17 | - if participants enter a negative number or a number outside the range supported (outside 0 - 10)
18 |
19 | ## Part 2: Weight Guru Challenge
20 | 1. Create a Java program that tells whether your body to weight ratio is good or could be better.
21 | 2. The java app should take in your weight and height from the console and calculate your body to weight ratio.
22 | 3. You can use [this article](https://www.rush.edu/health-wellness/quick-guides/what-is-a-healthy-weight) as a standardized guide for how to apply the logic.
23 |
--------------------------------------------------------------------------------
/Loops/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Loops
4 |
5 |
6 |
7 | ### Part 1: While loops
8 | 1. Open your IDE and create a new Java class named *Table*
9 | 2. Copy the following code into your Java class *Table* and verify it works
10 |
11 | ```java
12 |
13 | import java.util.Scanner;
14 |
15 | public class Table
16 | {
17 | public static void main(String[] args)
18 | {
19 | Scanner console = new Scanner(System.in);
20 | int num;
21 |
22 | System.out.print("Enter any positive integer: ");
23 | num = console.nextInt();
24 |
25 | System.out.println("Multiplication Table of " + num);
26 |
27 | //TODO implement While loop to get print result
28 | }
29 | }
30 | ```
31 | 3. Implement a *while* loop that prints out the multiplication table of the given input number.
32 |
33 | ### Part 2: Do While loops
34 | 1. Create a new Java class with a *main* method(so you can run your code) called *Fibonacci*
35 | 2. The *Fibonacci numbers* are a traditional computer science problem: "each number is the sum of the two preceding ones, starting from 0 and 1."
36 |
37 | The beginning of the sequence is thus:
38 |
39 | 0 1 1 2 3 5 8 13 21 34 55 89 ...
40 |
41 | 3. Add the following import to be able to capture user input n
42 |
43 | ```java
44 |
45 | import java.util.Scanner;
46 |
47 | ````
48 |
49 | 4. Implement a Do While loop that calculates Fibonacci(n)
50 |
51 |
52 | | n | Fibonacci(n) |
53 | | ------------- |:-------------:|
54 | | 0 | 0 |
55 | | 1 | 1 |
56 | | 2 | 1 |
57 | | 3 | 2 |
58 | | 4 | 3 |
59 | | 5 | 5 |
60 | | 6 | 8 |
61 | | 7 | 13 |
62 | | ... | ... |
63 |
64 | ### Part 3: For loops
65 | 1. Use the for loop to create a programm that ask the user to input a name and then prints each of the letters of the name
66 |
67 | *Hint* You can use the following String functions:
68 | - lenght() -> returns the total number of characters of a given String
69 | - chartAt(i) -> returns the character at the given position(*i*) of a String
70 |
71 | ### Challenge yourself
72 |
73 | Write a for loop that makes the counter go from 15 to 30, counting by 3s.
74 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Object Oriented Programming - Advanced
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Packages, Access Modifiers and Encapsulation
11 |
12 | 1. Download the source code, import the project into IntelliJ Idea and run it to verify it works correctly.
13 | 2. Go through the entire project and read the different classes and components trying to understand the logic behind.
14 | 3. Create at least two packages to organize your project better. Move the corresponding classes to the packages.
15 | 4. Modify the *Student* class so it follows the encapsulation principle keeping data private to the class.
16 | 5. Modify the *Course* class so it follows the encapsulation principle keeping data private to the class.
17 | 6. Modify the *StudentService* class so it follows the encapsulation principle:
18 | * Make data private so it can only be modified inside the class.
19 | * Create a method that lets you add students and use that in the *main* function.
20 |
21 |
22 | ## Part 2: Using collections with objects
23 | 1. Implment the following functions in the *StudentService* class:
24 |
25 | ```java
26 | public void showEnrolledStudents(String courseId){
27 | //TODO implement using collections loops
28 | }
29 |
30 | public void showAllCourses(){
31 | //TODO implement using collections loops
32 | }
33 | ```
34 | ## Part 3: Using Java Exeptions
35 | 1. Modify the *enrollStudents* method to verify:
36 | * if the Course does not exists throw a *CourseNotFoundException*.
37 | * if the Student does not exists throw a *StudentNotFoundException*.
38 |
39 | ```java
40 | public void enrollStudents( String courseName, String studentID )
41 | {
42 | Course course = courseList.get( courseName );
43 |
44 | if ( !coursesEnrolledByStudents.containsKey( studentID ) )
45 | {
46 | coursesEnrolledByStudents.put( studentID, new ArrayList<>() );
47 | }
48 | coursesEnrolledByStudents.get( studentID ).add( course );
49 | }
50 | ```
51 | ## Challenge yourselff
52 | 2. Modify the *unEnrollStudents* method to verify:
53 | * if the Course does not exists throw a *CourseNotFoundException*.
54 | * if the Student does not exists throw a *StudentNotFoundException*.
55 | ```java
56 | public void enrollStudents( String courseName, String studentID )
57 | {
58 | Course course = courseList.get( courseName );
59 |
60 | if ( !coursesEnrolledByStudents.containsKey( studentID ) )
61 | {
62 | coursesEnrolledByStudents.put( studentID, new ArrayList<>() );
63 | }
64 | coursesEnrolledByStudents.get( studentID ).add( course );
65 | }
66 | ```
67 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/Course.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Course
4 | {
5 | public String name;
6 |
7 | public int credits;
8 |
9 | public String professorName;
10 |
11 | public Course( String name, int credits, String professorName )
12 | {
13 | this.name = name;
14 | this.credits = credits;
15 | this.professorName = professorName;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/CourseNotFoundException.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class CourseNotFoundException extends Exception
4 | {
5 |
6 | public CourseNotFoundException()
7 | {
8 | super("course not found!!");
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | StudentService studentService = new StudentService();
7 | //TODO refactor this code to use encapsulation inside studentsService
8 | studentService.students.put( "1030", new Student( "Carlos", "1030", 31 ) );
9 | studentService.students.put( "1040", new Student( "Ian", "1020", 28 ) );
10 | studentService.students.put( "1050", new Student( "Elise", "1020", 26 ) );
11 | studentService.students.put( "1020", new Student( "Santiago", "1020", 33 ) );
12 |
13 | studentService.enrollStudents( "Math", "1030" );
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/Student.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.List;
6 |
7 | public class Student
8 | {
9 | public String name;
10 |
11 | public String id;
12 |
13 | public int age;
14 |
15 | public final List courseList = new ArrayList<>();
16 |
17 | public Student( String name, String id, int age)
18 | {
19 | this.name = name;
20 | this.id = id;
21 | this.age = age;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/StudentNotFoundException.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class StudentNotFoundException
4 | extends Exception
5 | {
6 |
7 | public StudentNotFoundException( )
8 | {
9 | super( "Student not found!" );
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Advanced/src/com/generation/StudentService.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | import java.util.ArrayList;
4 | import java.util.HashMap;
5 | import java.util.List;
6 |
7 | public class StudentService
8 | {
9 | HashMap courseList = new HashMap<>();
10 |
11 | HashMap students = new HashMap<>();
12 |
13 | HashMap> coursesEnrolledByStudents = new HashMap<>();
14 |
15 |
16 | public StudentService()
17 | {
18 | courseList.put( "Math", new Course( "Math", 10, "Aurelio Baldor" ) );
19 | courseList.put( "Physics", new Course( "Physics", 10, "Albert Einstein" ) );
20 | courseList.put( "Art", new Course( "Art", 10, "Pablo Picasso" ) );
21 | courseList.put( "History", new Course( "History", 10, "Sima Qian" ) );
22 | courseList.put( "Biology", new Course( "Biology", 10, "Charles Darwin" ) );
23 | }
24 |
25 | public void enrollStudents( String courseName, String studentID )
26 | {
27 | Course course = courseList.get( courseName );
28 |
29 | if ( !coursesEnrolledByStudents.containsKey( studentID ) )
30 | {
31 | coursesEnrolledByStudents.put( studentID, new ArrayList<>() );
32 | }
33 | coursesEnrolledByStudents.get( studentID ).add( course );
34 | }
35 |
36 | public void unEnrollStudents( String courseName, String studentID )
37 | {
38 | Course course = courseList.get( courseName );
39 |
40 | if ( coursesEnrolledByStudents.containsKey( studentID ) )
41 | {
42 | coursesEnrolledByStudents.get( studentID ).remove( course );
43 | }
44 | }
45 |
46 | public void showEnrolledStudents(String courseId){
47 | //TODO implement using collections loops
48 | }
49 |
50 | public void showAllCourses(){
51 | //TODO implement using collections loops
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Fundamentals/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Object Oriented Programming - Fundamentals
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Exploring the School System Project
11 |
12 | 1. Create a new Java project using IntelliJ Idea.
13 | 2. Create a *Student* class. This class must have the following attributes:
14 |
15 | ```java
16 | public class Student {
17 | String firstName;
18 | String lastName;
19 | int registration;
20 | int grade;
21 | int year;
22 | }
23 | ```
24 |
25 | 3. Now, make the *Student* class implement the following methods:
26 |
27 |
28 | ```java
29 | public void printFullName(){
30 | //TODO implement
31 | }
32 |
33 | public void isApproved(){
34 | //TODO implement: should return true if grade >= 60
35 | }
36 |
37 | public int changeYearIfApproved(){
38 | //TODO implement: the student should advance to the next year if he/she grade is >= 60
39 | // Make year = year + 1, and print "Congragulations" if the student has been approved
40 | return 0;
41 | }
42 | ```
43 |
44 | 4. Add constructors to your Student class:
45 |
46 | * Make the class with at least three different constructors.
47 |
48 | 5. Create a Java class for Courses
49 |
50 | * Your Course class must have, as attributes: courseName, professorName, year.
51 | * Your class must also contain a collection that lists all students enrolled in them.
52 | * Implement the following methods.
53 |
54 |
55 | ```java
56 | public void enroll(Student student){
57 | //TODO add the student to the collection
58 | }
59 |
60 | public void unEnroll(Student student){
61 | //TODO remove this student from the collection
62 | // Hint: check if that really is this student
63 | }
64 |
65 | public int countStudents(){
66 | //TODO implement
67 | return 0;
68 | }
69 |
70 | public int bestGrade(){
71 | //TODO implement
72 | return 0;
73 | }
74 | ```
75 |
76 | 6. Run the main method and verify that your implementation works.
77 |
78 | 7. Method Overload:
79 | * Overload the enroll method to take in an array of students.
80 |
81 | ```java
82 | public void enroll(Student[] students){
83 | //TODO add all the students to the collection
84 | }
85 | ```
86 | * Add on to the main method and call enroll with a list of students. Verify that your implementation works.
87 |
88 | ## Challenge yourself
89 |
90 | * Implement a function that calculates the average grade for that course.
91 | * Implement a function that outputs a ranking with all students enrolled in a course and respective grades.
92 | * Implement a function that, for each student, show if he/she is above course average or not.
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/Object Oriented Programming - Fundamentals/Theory session/1 -Myclass.java:
--------------------------------------------------------------------------------
1 | public class MyClass {
2 | int x = 5;
3 |
4 | public static void main(String[] args) {
5 | // To-do: instantiate your class
6 | // To-do: print the instantiated object's variable x
7 | System.out.println("Hello world");
8 | }
9 | }
--------------------------------------------------------------------------------
/Object Oriented Programming - Fundamentals/Theory session/1-Myclass-answer.java:
--------------------------------------------------------------------------------
1 | public class MyClass {
2 | int x = 5;
3 |
4 | public static void main(String[] args) {
5 | MyClass myObj = new MyClass();
6 | System.out.println(myObj.x);
7 | }
8 | }
--------------------------------------------------------------------------------
/Object Oriented Programming - Fundamentals/Theory session/2-Shoe-answer.java:
--------------------------------------------------------------------------------
1 | public class Shoe {
2 | String size;
3 | String color;
4 |
5 | public static void main(final String[] args) {
6 | Shoe myShoe = new Shoe();
7 | myShoe.size = "6.5";
8 | myShoe.color = "black";
9 |
10 | System.out.println(myShoe.size);
11 |
12 | }
13 | }
--------------------------------------------------------------------------------
/Polymorphism and Inheritance/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # Object Oriented Programming - Fundamentals
5 |
6 |
7 |
8 |
9 |
10 | ## Part 1: Exploring the HR System
11 |
12 | 1. Download the src folder and import the project into IntelliJ Idea
13 | 2. In this exercise, we'll create the Human Resources Management System mentioned in the theory section
14 | 3. Create the following class
15 |
16 |
17 | 
18 |
19 |
20 | Implement the methods:
21 |
22 |
23 | ```java
24 | public int timeToRetirement(){
25 | // time to retirement = min(60 - age, 40 - yearsWorked)
26 | }
27 |
28 | public int vacationTimeLeft(){
29 | // vacation time left = (daysWorked/360)*(30 - vacationDaysTaken)
30 | }
31 |
32 | public int calculateBonus(){
33 | // bonus = 2.2*salary
34 | }
35 | ```
36 |
37 | 4. Now, create a sales rep class that *inherits* the original employee class
38 | * The arrow used means inheritance in class diagrams
39 |
40 |
41 | 
42 |
43 |
44 | ```java
45 | public int calculateComission(){
46 | // comission = 0.1 * salesMade
47 | }
48 | ```
49 |
50 |
51 | 5. Create a Java Class for sales manager:
52 |
53 | 
54 |
55 | ```java
56 | public void calculateComission(){
57 | // 0.03 * all sales made by team
58 | }
59 | ```
60 |
61 | 6. Run the main method and verify that your implementation works.
62 |
63 | ## Challenge yourself
64 |
65 | * Turn the HR system into a login system. There should be an interface called user
66 | * The interface user should have username, password and implement the method login. The username and password must be private
67 | * The login() implementation should simply check if the username and password in parameters match the user's username and password
68 | * All employees should be users
69 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/Polymorphism and Inheritance/src/com/generation/Employee.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Employee {
4 | }
5 |
--------------------------------------------------------------------------------
/Polymorphism and Inheritance/src/com/generation/Main.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class Main {
4 |
5 | public static void main(String[] args) {
6 | // write your code here
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/Polymorphism and Inheritance/src/com/generation/SalesManager.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class SalesManager {
4 | }
5 |
--------------------------------------------------------------------------------
/Polymorphism and Inheritance/src/com/generation/SalesRep.java:
--------------------------------------------------------------------------------
1 | package com.generation;
2 |
3 | public class SalesRep {
4 | }
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Java Programming Fundamentals
4 | Practice Exercises for the Java Programming Fundamentals module developed by Generation.
5 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/README.md:
--------------------------------------------------------------------------------
1 | ### Unit Testing with JUnit
2 |
3 |
4 | #### Part 1: Writing Unit Tests
5 |
6 | 1. Open the Drive package and explore the classes and what they do.
7 |
8 | 2. Open the *DriversManagerTest* class and implement unit test for the following scenarios:
9 | * Verify a Passenger is added correctly
10 | * Verify a Driver is added correctly
11 |
12 | 3. Implement the following unit test in the *DriversManagerTest* class:
13 |
14 | ```java
15 | @Test
16 | public void startTripTest(){
17 |
18 | }
19 |
20 | @Test
21 | public void endTripTest(){
22 |
23 | }
24 | ```
25 | #### Part 2: Test Driven Development
26 | 1. Implement the following unit test so it fails:
27 | ```java
28 | @Test
29 | public void nextAvailableDriverTest(){
30 |
31 | }
32 | ```
33 | #### Part 3: Writing Tests for Edge Cases
34 | 1. Think of 2 edge cases that have not been tested. Write a unit test for each case.
35 |
36 | #### Challenge Yourself
37 | 1. As you can see this algorithm is not very fair. It does not consider distance so the drivers
38 | will always get paid the same fee. Modify the code so it considers distance too.
39 |
40 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/model/Calculator.java:
--------------------------------------------------------------------------------
1 | package calculator.model;
2 |
3 | public class Calculator
4 | {
5 |
6 | public int addNumbers(int num1, int num2){
7 | return num1 + num2;
8 | }
9 |
10 | public int subtractNumbers(int num1, int num2){
11 | return num1 - num2;
12 | }
13 |
14 | public int divideNumbers(int num1, int num2){
15 | return num1 / num2;
16 | }
17 |
18 | public int multiplyNumbers(int num1, int num2){
19 | return num1 * num2;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/model/drive/Driver.java:
--------------------------------------------------------------------------------
1 | package calculator.model.drive;
2 |
3 | public class Driver
4 | {
5 | private final String name;
6 |
7 | private final String id;
8 |
9 | private final double fee;
10 |
11 | private double balance;
12 |
13 | private boolean isAvailable = false;
14 |
15 | public Driver( String name, String id, double fee )
16 | {
17 | this.name = name;
18 | this.id = id;
19 | this.fee = fee;
20 | }
21 |
22 |
23 | public String getName()
24 | {
25 | return name;
26 | }
27 |
28 | public String getId()
29 | {
30 | return id;
31 | }
32 |
33 | public double getFee()
34 | {
35 | return fee;
36 | }
37 |
38 | public double getBalance()
39 | {
40 | return balance;
41 | }
42 |
43 | public boolean isAvailable()
44 | {
45 | return isAvailable;
46 | }
47 |
48 | public void startTrip()
49 | {
50 | isAvailable = false;
51 | }
52 |
53 | public void endTrip()
54 | {
55 | isAvailable = true;
56 | balance += balance;
57 | }
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/model/drive/DriversManager.java:
--------------------------------------------------------------------------------
1 | package calculator.model.drive;
2 |
3 | import java.util.HashMap;
4 |
5 | public class DriversManager
6 | {
7 | private final HashMap passengersMap = new HashMap<>();
8 |
9 | private final HashMap driversMap = new HashMap<>();
10 |
11 | public void addPassenger( Passenger passenger )
12 | {
13 | passengersMap.put( passenger.getId(), passenger );
14 | }
15 |
16 | public void addDriver( Driver driver )
17 | {
18 | driversMap.put( driver.getId(), driver );
19 | }
20 |
21 | public Driver getDriver( String driverId )
22 | {
23 | return driversMap.getOrDefault( driverId, null );
24 | }
25 |
26 | public Passenger getPassenger( String passengerId )
27 | {
28 | return passengersMap.getOrDefault( passengerId, null );
29 | }
30 |
31 | public void startTrip( String passengerId, String driverId )
32 | {
33 | if ( passengersMap.containsKey( passengerId ) && driversMap.containsKey( driverId ) )
34 | {
35 | Passenger passenger = passengersMap.get( passengerId );
36 | passenger.startTrip();
37 | Driver driver = driversMap.get( driverId );
38 | driver.startTrip();
39 | }
40 | }
41 |
42 | public void endTrip( String passengerId, String driverId )
43 | {
44 | if ( passengersMap.containsKey( passengerId ) && driversMap.containsKey( driverId ) )
45 | {
46 | Driver driver = driversMap.get( driverId );
47 | driver.endTrip();
48 | Passenger passenger = passengersMap.get( passengerId );
49 | passenger.endTrip( driver.getFee() );
50 | }
51 | }
52 |
53 | public String findNextAvailableDriver()
54 | {
55 | return "driver_id";
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/model/drive/DriversManagerTest.java:
--------------------------------------------------------------------------------
1 | package calculator.model.drive;
2 |
3 | import org.junit.Test;
4 | import org.junit.Before;
5 |
6 |
7 | public class DriversManagerTest
8 | {
9 |
10 | private final DriversManager driversManager = new DriversManager();
11 |
12 | @Before
13 | public void setup(){
14 | driversManager.addPassenger( new Passenger( "Carlos", "44234", 100 ) );
15 | driversManager.addPassenger( new Passenger( "Elise", "533434", 100 ) );
16 | driversManager.addPassenger( new Passenger( "Ian", "5343433", 100 ) );
17 | driversManager.addPassenger( new Passenger( "Debbie", "44555521", 100 ) );
18 | driversManager.addPassenger( new Passenger( "Cleon", "559988", 100 ) );
19 | driversManager.addPassenger( new Passenger( "Santiago", "1203123", 100 ) );
20 |
21 | driversManager.addDriver( new Driver( "Emilio", "1234990", 10f ) );
22 | driversManager.addDriver( new Driver( "Pedro", "12312440", 12f ) );
23 | driversManager.addDriver( new Driver( "Constanza", "9824990", 11f ) );
24 | }
25 |
26 | @Test
27 | public void startTripTest(){
28 |
29 | }
30 |
31 | @Test
32 | public void endTripTest(){
33 |
34 | }
35 |
36 | @Test
37 | public void nextAvailableDriverTest(){
38 |
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/model/drive/Passenger.java:
--------------------------------------------------------------------------------
1 | package calculator.model.drive;
2 |
3 | public class Passenger
4 | {
5 |
6 | private final String name;
7 |
8 | private final String id;
9 |
10 | private double balance = 0;
11 |
12 | private boolean isOnTrip = false;
13 |
14 | public Passenger( String name, String id )
15 | {
16 | this.name = name;
17 | this.id = id;
18 | }
19 |
20 | public void addBalance( double balance )
21 | {
22 | this.balance += balance;
23 | }
24 |
25 | public boolean hasEnoughBalance( double balance )
26 | {
27 | return this.balance > balance;
28 | }
29 |
30 | public Passenger( String name, String id, double balance )
31 | {
32 | this.name = name;
33 | this.id = id;
34 | this.balance = balance;
35 | }
36 |
37 | public String getName()
38 | {
39 | return name;
40 | }
41 |
42 | public String getId()
43 | {
44 | return id;
45 | }
46 |
47 | public double getBalance()
48 | {
49 | return balance;
50 | }
51 |
52 | public Boolean isOnTrip() { return isOnTrip; }
53 |
54 | public void startTrip()
55 | {
56 | isOnTrip = true;
57 | }
58 |
59 | public void endTrip( double fee )
60 | {
61 | balance -= fee;
62 | isOnTrip = false;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/tdd/CalculatorTDD.java:
--------------------------------------------------------------------------------
1 | package calculator.tdd;
2 |
3 | public class CalculatorTDD
4 | {
5 | public int addNumbers(int num1, int num2){
6 | return 0;
7 | }
8 |
9 | public int subtractNumbers(int num1, int num2){
10 | return 0;
11 | }
12 |
13 | public int divideNumbers(int num1, int num2){
14 | return 0;
15 | }
16 |
17 | public int multiplyNumbers(int num1, int num2){
18 | return 0;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/tdd/CalculatorTDDTest.java:
--------------------------------------------------------------------------------
1 | package calculator.tdd;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.assertEquals;
6 |
7 | public class CalculatorTDDTest
8 | {
9 |
10 |
11 | CalculatorTDD calculatorTDD = new CalculatorTDD();
12 |
13 | @Test
14 | public void addTest()
15 | {
16 | assertEquals( 7, calculatorTDD.addNumbers( 5, 3 ) );
17 | }
18 |
19 |
20 | @Test
21 | public void subtractTest()
22 | {
23 | assertEquals( 5, calculatorTDD.subtractNumbers( 10, 5 ) );
24 | }
25 |
26 |
27 | @Test
28 | public void multiplyTest()
29 | {
30 | assertEquals( 15, calculatorTDD.multiplyNumbers( 5, 3 ) );
31 | }
32 |
33 |
34 | @Test
35 | public void divideTest()
36 | {
37 | assertEquals( 7, calculatorTDD.divideNumbers( 5, 0 ) );
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Unit Testing with JUnit/src/calculator/test/CalculatorTest.java:
--------------------------------------------------------------------------------
1 | package calculator.test;
2 |
3 | import calculator.model.Calculator;
4 | import org.junit.Test;
5 |
6 | import static org.junit.Assert.assertEquals;
7 |
8 | public class CalculatorTest
9 | {
10 |
11 | Calculator calculator = new Calculator();
12 |
13 | @Test
14 | public void addTest()
15 | {
16 | assertEquals( 7, calculator.addNumbers( 5, 3 ) );
17 | }
18 |
19 |
20 | @Test
21 | public void subtractTest()
22 | {
23 | assertEquals( 5, calculator.subtractNumbers( 10, 5 ) );
24 | }
25 |
26 |
27 | @Test
28 | public void multiplyTest()
29 | {
30 | assertEquals( 15, calculator.multiplyNumbers( 5, 3 ) );
31 | }
32 |
33 |
34 | @Test
35 | public void divideTest()
36 | {
37 | assertEquals( 7, calculator.divideNumbers( 5, 0 ) );
38 | }
39 |
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/Variables, Data Types and Operators/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | # JAVA-3 Variables, Data Types and Operators
5 |
6 |
7 |
8 |
9 |
10 | ## Activity 1 (Introduction): My First Input
11 | 1. Open your IntelliJ Idea IDE and follow the instructions below
12 | 2. Create a project called 'MyFirstInput'
13 | 3. Create a class called MyFirstInput
14 | 4. Add a main method to your app.
15 | 5. Make your code looks like the file shown below
16 |
17 | ```java
18 | package com.generation.java;
19 | import java.io.Console;
20 |
21 | class MyFirstInput {
22 | public static void main(String[] args) {
23 | Console console = System.console();
24 | System.out.println("Please enter your name ");
25 | String name = console.readLine();
26 |
27 | System.out.println("My name is "+ name);
28 | }
29 | }
30 |
31 | ```
32 |
33 | 6. Run your application.
34 | 7. Notice the prompt on the IntelliJ console asking you to enter your name.
35 | 8. Have a discussion with your pair partner on what you think each line of the code above does.
36 |
37 | ## Activity 2: My First Variable Naming
38 |
39 | 1. Open your IntelliJ Idea IDE and follow the instructions below
40 | 2. Create a project called MyFirstVariableNaming
41 | 3. Create a class titled "UserProfile"
42 | 4. Write code so that the app stores a users name, age, gender, job preference, nationality and blood type
43 | 5. Think about what variable names you want to assign to the properties above and variable name conventions to be followed.
44 | 6. Use the age to calculate the year when a user was born.
45 | 7. Print the values back to a user's console.
46 |
47 | ### Extra features
48 | If you're able to implement the steps above with time to spare, add the following features to your app.
49 | 1. Instead of storing values in the static variables (variables manually assigned to values), have it so that a few variables are entered by a user through the console.
50 |
51 |
52 | ## Activity 3: Variable Naming and Type Casting
53 | 1. Open your IntelliJ Idea IDE and follow the instructions below
54 | 2. Create a project on IntelliJ. This time feel free to give it an appropriate name. *hint* We're going to be finding the area and perimeter of a circle.
55 | 3. Write a java application that prompts a user to enter the diameter of a circle and calculates the area and perimeter of the circle.
56 | 4. Perform a widening casting operation (integer to double) when storing the result of the operations.
57 | 5. Print out the results of the two operations in the console.
58 |
59 | ### Extra features
60 | If you're able to implement the steps above with time to spare, check on your pair partner and ask if they need help.
61 |
--------------------------------------------------------------------------------