From c00f8cbaea92c7c65c1ca4e629461146ce287e06 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 13:03:21 -0700 Subject: [PATCH 01/21] initial commit --- Day 3/Abstraction/Abstraction.md | 13 +++++++++++++ Day 3/Encapsulation/Encapsulation.md | 13 +++++++++++++ Day 3/Inheritance/Inheritance.md | 13 +++++++++++++ Day 3/Polymorphism/Polymorphism.md | 13 +++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 Day 3/Abstraction/Abstraction.md create mode 100644 Day 3/Encapsulation/Encapsulation.md create mode 100644 Day 3/Inheritance/Inheritance.md create mode 100644 Day 3/Polymorphism/Polymorphism.md diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md new file mode 100644 index 0000000..c1d379a --- /dev/null +++ b/Day 3/Abstraction/Abstraction.md @@ -0,0 +1,13 @@ +# Abstraction 🍡 + +### Task 🐧 +``` +Create code that completes the following task: + + +``` +### Requirements 🏫 +``` +1. A .java file +2. +``` \ No newline at end of file diff --git a/Day 3/Encapsulation/Encapsulation.md b/Day 3/Encapsulation/Encapsulation.md new file mode 100644 index 0000000..d9f633e --- /dev/null +++ b/Day 3/Encapsulation/Encapsulation.md @@ -0,0 +1,13 @@ +# Encapsulation 🍡 + +### Task 🐧 +``` +Create code that completes the following task: + + +``` +### Requirements 🏫 +``` +1. A .java file +2. +``` \ No newline at end of file diff --git a/Day 3/Inheritance/Inheritance.md b/Day 3/Inheritance/Inheritance.md new file mode 100644 index 0000000..1b16cf4 --- /dev/null +++ b/Day 3/Inheritance/Inheritance.md @@ -0,0 +1,13 @@ +# Inheritance 🍡 + +### Task 🐧 +``` +Create code that completes the following task: + + +``` +### Requirements 🏫 +``` +1. A .java file +2. +``` \ No newline at end of file diff --git a/Day 3/Polymorphism/Polymorphism.md b/Day 3/Polymorphism/Polymorphism.md new file mode 100644 index 0000000..e0493dd --- /dev/null +++ b/Day 3/Polymorphism/Polymorphism.md @@ -0,0 +1,13 @@ +# Polymorphism 🍡 + +### Task 🐧 +``` +Create code that completes the following task: + + +``` +### Requirements 🏫 +``` +1. A .java file +2. +``` \ No newline at end of file From b85b6ab6e73129c639e269339cde0e59c42b15ad Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 13:26:25 -0700 Subject: [PATCH 02/21] abstraction activity --- Day 3/Abstraction/Abstraction.md | 34 ++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md index c1d379a..10da8f8 100644 --- a/Day 3/Abstraction/Abstraction.md +++ b/Day 3/Abstraction/Abstraction.md @@ -2,12 +2,42 @@ ### Task 🐧 ``` -Create code that completes the following task: +Create an abstract class called Shirt: + - Make an instance variable called color + - Make a constructor that takes a String for the color & sets it to the instance variable + - Make a public method called `getColor()` that returns the name of the color + - Make EMPTY abstract methods, getSize() and getPrice() +Create a default class called `T_Shirt` that extends Shirt: + - Make an instance variable called size + - Make an instance variable called price + - Make a constructor that takes in a color and a size and sets the instance variables (Use super() to call the constructor of Shirt) + - Make a method called `getSize()` that returns the size of the shirt in a string + - Make a method called `getPrice()` that returns the price of the shirt in a string + - Make a method called `getColor()` that returns the color of the shirt (Use super() to call the constructor of Shirt) +Create another default class called 'Jacket' that extends Shirt: + - Make and instance variable that is a boolean called isZip + - Make an instance variable called price + - Make an instance variable called size + - Make a constructor that takes in a color, price, and isZip and sets the instance variables (Use super() to call the constructor of Shirt) + - Make a method called `getSize()` that returns the size of the shirt in a string + - Make a method called `getPrice()` that returns the price of the shirt + - Make a method called `getColor()` that returns the color of the shirt (Use super() to call the constructor of Shirt) + +In public static void main(String[] args): + - Create an instance of T_Shirt + - Create an instance of Jacket + - Print the color & size of the T_Shirt + - Print the color & size of the Jacket + - Print the isZip of the Jacket + - Print the total price of both the T_Shirt and the Jacket ``` ### Requirements 🏫 ``` 1. A .java file -2. +2. Prints the color & size of a T_Shirt +3. Prints the color & size of a Jacket +4. Prints the isZip of a Jacket +5. Prints the total price of the items ``` \ No newline at end of file From b9ba71fc6f76a7a1b2ec6e4048051025aa831b8f Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 13:37:31 -0700 Subject: [PATCH 03/21] fix wording --- Day 3/Abstraction/Abstraction.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md index 10da8f8..f61a700 100644 --- a/Day 3/Abstraction/Abstraction.md +++ b/Day 3/Abstraction/Abstraction.md @@ -12,18 +12,16 @@ Create a default class called `T_Shirt` that extends Shirt: - Make an instance variable called size - Make an instance variable called price - Make a constructor that takes in a color and a size and sets the instance variables (Use super() to call the constructor of Shirt) - - Make a method called `getSize()` that returns the size of the shirt in a string - - Make a method called `getPrice()` that returns the price of the shirt in a string - - Make a method called `getColor()` that returns the color of the shirt (Use super() to call the constructor of Shirt) + - Override the method called `getSize()` that returns the size of the shirt in a string + - Override the method called `getPrice()` that returns the price of the shirt in a string Create another default class called 'Jacket' that extends Shirt: - Make and instance variable that is a boolean called isZip - Make an instance variable called price - Make an instance variable called size - Make a constructor that takes in a color, price, and isZip and sets the instance variables (Use super() to call the constructor of Shirt) - - Make a method called `getSize()` that returns the size of the shirt in a string - - Make a method called `getPrice()` that returns the price of the shirt - - Make a method called `getColor()` that returns the color of the shirt (Use super() to call the constructor of Shirt) + - Ovveride the method `getSize()` that returns the size of the shirt in a string + - Override the method called `getPrice()` that returns the price of the shirt In public static void main(String[] args): - Create an instance of T_Shirt From c993fbcfe6246bfae9275e5ae0f21621d79a7a12 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 13:52:56 -0700 Subject: [PATCH 04/21] getDescription() --- Day 3/Abstraction/Abstraction.md | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md index f61a700..896e487 100644 --- a/Day 3/Abstraction/Abstraction.md +++ b/Day 3/Abstraction/Abstraction.md @@ -6,30 +6,25 @@ Create an abstract class called Shirt: - Make an instance variable called color - Make a constructor that takes a String for the color & sets it to the instance variable - Make a public method called `getColor()` that returns the name of the color - - Make EMPTY abstract methods, getSize() and getPrice() + - Make an empty abstract method called `getDescription()` Create a default class called `T_Shirt` that extends Shirt: - Make an instance variable called size - Make an instance variable called price - - Make a constructor that takes in a color and a size and sets the instance variables (Use super() to call the constructor of Shirt) - - Override the method called `getSize()` that returns the size of the shirt in a string - - Override the method called `getPrice()` that returns the price of the shirt in a string + - Make a constructor that takes in a color, size, price and sets the instance variables (Use super() to call the constructor of Shirt) + - Override the method called `getDescription()` that returns the color, size, and price of the T_Shirt Create another default class called 'Jacket' that extends Shirt: - - Make and instance variable that is a boolean called isZip - Make an instance variable called price - - Make an instance variable called size + - Make an instance variable called brand - Make a constructor that takes in a color, price, and isZip and sets the instance variables (Use super() to call the constructor of Shirt) - - Ovveride the method `getSize()` that returns the size of the shirt in a string - - Override the method called `getPrice()` that returns the price of the shirt + - Override the method called `getDescription()` that returns the color, brand, and price of the T_Shirt In public static void main(String[] args): - Create an instance of T_Shirt - Create an instance of Jacket - - Print the color & size of the T_Shirt - - Print the color & size of the Jacket - - Print the isZip of the Jacket - - Print the total price of both the T_Shirt and the Jacket + - Print the description of the T_Shirt + - Print the description of the Jacket ``` ### Requirements 🏫 ``` From 20fd4163e497e9ab8a633a47e303589e669ba8e7 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 14:34:51 -0700 Subject: [PATCH 05/21] Create inheritance --- Day 3/Inheritance/Inheritance.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Day 3/Inheritance/Inheritance.md b/Day 3/Inheritance/Inheritance.md index 1b16cf4..d3d3003 100644 --- a/Day 3/Inheritance/Inheritance.md +++ b/Day 3/Inheritance/Inheritance.md @@ -2,12 +2,24 @@ ### Task 🐧 ``` -Create code that completes the following task: +Create a class called Parent: + - Make an instance variable called last_name + - Make an instace variable called hair color + - Create a constructor and set all the instace varaiables to the parameters passed in + - Make a public method called `getLastName()` that returns the last name +Create a class called 'Child' that inherits (extends) Parent: + - Make an instance variable called first_name + - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name, height, and hair color) + - Create a method that returns the first and last name in a String + - Create a method that returns the hair color of the parent +In public static void main(String[] args) + - Create an instance of Child + - Print out the first and last name of the child ``` ### Requirements 🏫 ``` 1. A .java file -2. +2. Prints the first and last name of the child ``` \ No newline at end of file From e1de50bb961f571aeca94203dea46d50d875f839 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 15:56:15 -0700 Subject: [PATCH 06/21] update reqs & task --- Day 3/Abstraction/Abstraction.md | 6 ------ Day 3/Inheritance/Inheritance.md | 11 ++++------- Day 3/Polymorphism/Polymorphism.md | 10 ++++++++-- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md index 896e487..fb94f92 100644 --- a/Day 3/Abstraction/Abstraction.md +++ b/Day 3/Abstraction/Abstraction.md @@ -19,12 +19,6 @@ Create another default class called 'Jacket' that extends Shirt: - Make an instance variable called brand - Make a constructor that takes in a color, price, and isZip and sets the instance variables (Use super() to call the constructor of Shirt) - Override the method called `getDescription()` that returns the color, brand, and price of the T_Shirt - -In public static void main(String[] args): - - Create an instance of T_Shirt - - Create an instance of Jacket - - Print the description of the T_Shirt - - Print the description of the Jacket ``` ### Requirements 🏫 ``` diff --git a/Day 3/Inheritance/Inheritance.md b/Day 3/Inheritance/Inheritance.md index d3d3003..6259cef 100644 --- a/Day 3/Inheritance/Inheritance.md +++ b/Day 3/Inheritance/Inheritance.md @@ -4,22 +4,19 @@ ``` Create a class called Parent: - Make an instance variable called last_name - - Make an instace variable called hair color + - Make an instace variable called eye color - Create a constructor and set all the instace varaiables to the parameters passed in - Make a public method called `getLastName()` that returns the last name Create a class called 'Child' that inherits (extends) Parent: - Make an instance variable called first_name - - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name, height, and hair color) + - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) - Create a method that returns the first and last name in a String - - Create a method that returns the hair color of the parent - -In public static void main(String[] args) - - Create an instance of Child - - Print out the first and last name of the child + - Create a method that returns the eye color color of the parent ``` ### Requirements 🏫 ``` 1. A .java file 2. Prints the first and last name of the child +3. Prints the eye color of the parent ``` \ No newline at end of file diff --git a/Day 3/Polymorphism/Polymorphism.md b/Day 3/Polymorphism/Polymorphism.md index e0493dd..1c542e2 100644 --- a/Day 3/Polymorphism/Polymorphism.md +++ b/Day 3/Polymorphism/Polymorphism.md @@ -2,12 +2,18 @@ ### Task 🐧 ``` -Create code that completes the following task: +Create a class called 'Calculator' + - Make the a method division that divides two ints & overload it to divide two doubles + - Make the a method multiplication that multiplies two ints +Create a class called 'SlowCalculator' that extends Calculator: + - Override the multiply method and use a loop to calculate the product of the two ints ``` ### Requirements 🏫 ``` 1. A .java file -2. +2. Prints the exact qutient of 39 and 49 +3. Prints the rounded quotient of 37 and 49 +4. Prints the product of 37 and 49 ``` \ No newline at end of file From 0b1ea18f5ac3de81c71390e998643da18fe19ae7 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 16:21:28 -0700 Subject: [PATCH 07/21] update isZip --- Day 3/Abstraction/Abstraction.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/Abstraction.md index fb94f92..65fdd77 100644 --- a/Day 3/Abstraction/Abstraction.md +++ b/Day 3/Abstraction/Abstraction.md @@ -17,7 +17,7 @@ Create a default class called `T_Shirt` that extends Shirt: Create another default class called 'Jacket' that extends Shirt: - Make an instance variable called price - Make an instance variable called brand - - Make a constructor that takes in a color, price, and isZip and sets the instance variables (Use super() to call the constructor of Shirt) + - Make a constructor that takes in a color, and price, and sets the instance variables (Use super() to call the constructor of Shirt) - Override the method called `getDescription()` that returns the color, brand, and price of the T_Shirt ``` ### Requirements 🏫 From a2633060a344a311d9e5c7d5f2cedba93a63a0b3 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 16:38:17 -0700 Subject: [PATCH 08/21] encapsulation activity --- Day 3/Encapsulation/Encapsulation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Day 3/Encapsulation/Encapsulation.md b/Day 3/Encapsulation/Encapsulation.md index d9f633e..ef6ca54 100644 --- a/Day 3/Encapsulation/Encapsulation.md +++ b/Day 3/Encapsulation/Encapsulation.md @@ -2,12 +2,12 @@ ### Task 🐧 ``` -Create code that completes the following task: - - +Create a private class called "BankAccount" + - Initialize private variables, name, balance, and email + - Create getters & setters for all of these variables ``` ### Requirements 🏫 ``` 1. A .java file -2. +2. Prints the name, email, and balance of the account ``` \ No newline at end of file From 6aff4bbadcf3d18aa1f566b5fddf7c1115cdbde6 Mon Sep 17 00:00:00 2001 From: Ple1ades <83891895+Ple1ades@users.noreply.github.com> Date: Mon, 4 Jul 2022 18:10:50 -0700 Subject: [PATCH 09/21] Update Encapsulation.md --- Day 3/Encapsulation/Encapsulation.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Day 3/Encapsulation/Encapsulation.md b/Day 3/Encapsulation/Encapsulation.md index d9f633e..41084e5 100644 --- a/Day 3/Encapsulation/Encapsulation.md +++ b/Day 3/Encapsulation/Encapsulation.md @@ -2,12 +2,20 @@ ### Task 🐧 ``` -Create code that completes the following task: - - +Create a class callsed Information: + - Make private variables for name, age, and gender + - Create getters and setters for each of the private variables + - Create a boolean getter for if they are above the age of 21 + +In public static void main(String[] args): + - Create two instances of Information + - Set the name and gender to whatever you want + - Set the age to less than 21 for one and above 21 for the other + - Print out if they are above the age of 21 with their name and gender ``` ### Requirements 🏫 ``` 1. A .java file -2. -``` \ No newline at end of file +2. Print out the name and gender of two people +3. Print out if said people are above the age of 21 +``` From 44c7c8446dbb646ed4b230d4456b9b83e1257412 Mon Sep 17 00:00:00 2001 From: rohin Date: Wed, 21 Sep 2022 18:36:22 -0700 Subject: [PATCH 10/21] delete printing.md --- Printing/Printing.md | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 Printing/Printing.md diff --git a/Printing/Printing.md b/Printing/Printing.md deleted file mode 100644 index 44ae064..0000000 --- a/Printing/Printing.md +++ /dev/null @@ -1,20 +0,0 @@ -# Printing 🍡 - -### Task 🐧 -``` -Create a .java file and print out the phrase "Java is Cool!" on one line, and the phrase, "Your mom is cooler!" on the next -``` -### Requirements 🏫 -``` -1. A .java file -2. A .class file -3. Prints "Java is Cool!" and "Your mom is cooler!" on two seperate lines when run -``` -
-Hints 🀫 -
    -
  1. public static void main(String[] args)
  2. -
  3. Use escape characters
  4. -
  5. Compile & Run!
  6. -
-
From dc924b6bdbe2baae9ba1b2f33b822ccbfa13fb38 Mon Sep 17 00:00:00 2001 From: rohin Date: Wed, 21 Sep 2022 18:49:59 -0700 Subject: [PATCH 11/21] update PR part of how to use --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 091a4f3..2edefbc 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,17 @@

- + Change the base repository to YOUR FORK not Team-Optix-3749: Java-Training +
SHOULD NOT look like this
+ +
SHOULD look like this
+
- +
- +
- +
From 1984bb71e1041f21ab0d3547df01a6c91ab51caf Mon Sep 17 00:00:00 2001 From: rohin Date: Wed, 21 Sep 2022 19:04:21 -0700 Subject: [PATCH 12/21] rename files to README.md --- Day 3/Abstraction/{Abstraction.md => README.md} | 0 Day 3/Encapsulation/{Encapsulation.md => README.md} | 0 Day 3/Inheritance/{Inheritance.md => README.md} | 0 Day 3/Polymorphism/{Polymorphism.md => README.md} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename Day 3/Abstraction/{Abstraction.md => README.md} (100%) rename Day 3/Encapsulation/{Encapsulation.md => README.md} (100%) rename Day 3/Inheritance/{Inheritance.md => README.md} (100%) rename Day 3/Polymorphism/{Polymorphism.md => README.md} (100%) diff --git a/Day 3/Abstraction/Abstraction.md b/Day 3/Abstraction/README.md similarity index 100% rename from Day 3/Abstraction/Abstraction.md rename to Day 3/Abstraction/README.md diff --git a/Day 3/Encapsulation/Encapsulation.md b/Day 3/Encapsulation/README.md similarity index 100% rename from Day 3/Encapsulation/Encapsulation.md rename to Day 3/Encapsulation/README.md diff --git a/Day 3/Inheritance/Inheritance.md b/Day 3/Inheritance/README.md similarity index 100% rename from Day 3/Inheritance/Inheritance.md rename to Day 3/Inheritance/README.md diff --git a/Day 3/Polymorphism/Polymorphism.md b/Day 3/Polymorphism/README.md similarity index 100% rename from Day 3/Polymorphism/Polymorphism.md rename to Day 3/Polymorphism/README.md From e60c250c2bd92b1e5ea3f28b445f9ee469bceec5 Mon Sep 17 00:00:00 2001 From: rohin Date: Sun, 25 Sep 2022 05:51:41 -0700 Subject: [PATCH 13/21] =?UTF-8?q?Move=20activites=20into=20"week=203"=20an?= =?UTF-8?q?d=20create=20lambdas=20=F0=9F=98=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Day 3/Abstraction/README.md | 30 ------------------------------ Day 3/Encapsulation/README.md | 19 ------------------- Day 3/Inheritance/README.md | 22 ---------------------- Day 3/Polymorphism/README.md | 19 ------------------- Week 3/Abstraction/README.md | 29 +++++++++++++++++++++++++++++ Week 3/Classes & Objects/README.md | 13 +++++++++++++ Week 3/Encapsulation/README.md | 14 ++++++++++++++ Week 3/Inheritance/README.md | 21 +++++++++++++++++++++ Week 3/Lambdas/README.md | 13 +++++++++++++ Week 3/Non-Void Methods/README.md | 16 ++++++++++++++++ Week 3/Polymorphism/README.md | 17 +++++++++++++++++ Week 3/Void Methods/README.md | 12 ++++++++++++ 12 files changed, 135 insertions(+), 90 deletions(-) delete mode 100644 Day 3/Abstraction/README.md delete mode 100644 Day 3/Encapsulation/README.md delete mode 100644 Day 3/Inheritance/README.md delete mode 100644 Day 3/Polymorphism/README.md create mode 100644 Week 3/Abstraction/README.md create mode 100644 Week 3/Classes & Objects/README.md create mode 100644 Week 3/Encapsulation/README.md create mode 100644 Week 3/Inheritance/README.md create mode 100644 Week 3/Lambdas/README.md create mode 100644 Week 3/Non-Void Methods/README.md create mode 100644 Week 3/Polymorphism/README.md create mode 100644 Week 3/Void Methods/README.md diff --git a/Day 3/Abstraction/README.md b/Day 3/Abstraction/README.md deleted file mode 100644 index 65fdd77..0000000 --- a/Day 3/Abstraction/README.md +++ /dev/null @@ -1,30 +0,0 @@ -# Abstraction 🍡 - -### Task 🐧 -``` -Create an abstract class called Shirt: - - Make an instance variable called color - - Make a constructor that takes a String for the color & sets it to the instance variable - - Make a public method called `getColor()` that returns the name of the color - - Make an empty abstract method called `getDescription()` - -Create a default class called `T_Shirt` that extends Shirt: - - Make an instance variable called size - - Make an instance variable called price - - Make a constructor that takes in a color, size, price and sets the instance variables (Use super() to call the constructor of Shirt) - - Override the method called `getDescription()` that returns the color, size, and price of the T_Shirt - -Create another default class called 'Jacket' that extends Shirt: - - Make an instance variable called price - - Make an instance variable called brand - - Make a constructor that takes in a color, and price, and sets the instance variables (Use super() to call the constructor of Shirt) - - Override the method called `getDescription()` that returns the color, brand, and price of the T_Shirt -``` -### Requirements 🏫 -``` -1. A .java file -2. Prints the color & size of a T_Shirt -3. Prints the color & size of a Jacket -4. Prints the isZip of a Jacket -5. Prints the total price of the items -``` \ No newline at end of file diff --git a/Day 3/Encapsulation/README.md b/Day 3/Encapsulation/README.md deleted file mode 100644 index a41a280..0000000 --- a/Day 3/Encapsulation/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Encapsulation 🍡 - -### Task 🐧 -``` -Create a class callsed Information: - - Make private variables for name, age, and gender - - Create getters and setters for each of the private variables - - Create a boolean getter for if they are above the age of 21 - -In public static void main(String[] args): - - Create two instances of Information with different names & genders & ages either above or below 21 - - Print out if they are above the age of 21 with their name and gender -``` -### Requirements 🏫 -``` -1. A .java file -2. Print out the name and gender of two people -3. Print out if said people are above the age of 21 -``` diff --git a/Day 3/Inheritance/README.md b/Day 3/Inheritance/README.md deleted file mode 100644 index 6259cef..0000000 --- a/Day 3/Inheritance/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Inheritance 🍡 - -### Task 🐧 -``` -Create a class called Parent: - - Make an instance variable called last_name - - Make an instace variable called eye color - - Create a constructor and set all the instace varaiables to the parameters passed in - - Make a public method called `getLastName()` that returns the last name - -Create a class called 'Child' that inherits (extends) Parent: - - Make an instance variable called first_name - - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) - - Create a method that returns the first and last name in a String - - Create a method that returns the eye color color of the parent -``` -### Requirements 🏫 -``` -1. A .java file -2. Prints the first and last name of the child -3. Prints the eye color of the parent -``` \ No newline at end of file diff --git a/Day 3/Polymorphism/README.md b/Day 3/Polymorphism/README.md deleted file mode 100644 index 1c542e2..0000000 --- a/Day 3/Polymorphism/README.md +++ /dev/null @@ -1,19 +0,0 @@ -# Polymorphism 🍡 - -### Task 🐧 -``` -Create a class called 'Calculator' - - Make the a method division that divides two ints & overload it to divide two doubles - - Make the a method multiplication that multiplies two ints - -Create a class called 'SlowCalculator' that extends Calculator: - - Override the multiply method and use a loop to calculate the product of the two ints - -``` -### Requirements 🏫 -``` -1. A .java file -2. Prints the exact qutient of 39 and 49 -3. Prints the rounded quotient of 37 and 49 -4. Prints the product of 37 and 49 -``` \ No newline at end of file diff --git a/Week 3/Abstraction/README.md b/Week 3/Abstraction/README.md new file mode 100644 index 0000000..42b4eab --- /dev/null +++ b/Week 3/Abstraction/README.md @@ -0,0 +1,29 @@ +# Abstraction 🍡 + +### Task 🐧 + - Create an abstract class called Shirt: + - Make an instance variable called color + - Make a constructor that takes a String for the color & sets it to the instance variable + - Make a public method called `getColor()` that returns the name of the color + - Make an empty abstract method called `getDescription()` + + - Create a default class called `T_Shirt` that extends Shirt: + - Make an instance variable called size + - Make an instance variable called price + - Make a constructor that takes in a color, size, price and sets the instance variables (Use super() to call the constructor of Shirt) + - Override the method called `getDescription()` that returns the color, size, and price of the T_Shirt + + - Create another default class called 'Jacket' that extends Shirt: + - Make an instance variable called price + - Make an instance variable called brand + - Make a constructor that takes in a color, and price, and sets the instance variables (Use super() to call the constructor of Shirt) + - Override the method called `getDescription()` that returns the color, brand, and price of the T_Shirt + +### Requirements 🏫 +``` +1. A .java file +2. Prints the color & size of a T_Shirt +3. Prints the color & size of a Jacket +4. Prints the isZip of a Jacket +5. Prints the total price of the items +``` \ No newline at end of file diff --git a/Week 3/Classes & Objects/README.md b/Week 3/Classes & Objects/README.md new file mode 100644 index 0000000..7b8465a --- /dev/null +++ b/Week 3/Classes & Objects/README.md @@ -0,0 +1,13 @@ +# Classes and Objects 🍡 + +### Task 🐧 + - Create a class called "Me" & intialize variables name and age + - Create parameters for these variables and set them to the variables in the constructor + - Create 2 method that returns your name and age + - Create an object for this class in the main method, & use the method to print! + +### Requirements 🏫 +``` +1. A .java file +2. Prints your name and age from the Me object +``` \ No newline at end of file diff --git a/Week 3/Encapsulation/README.md b/Week 3/Encapsulation/README.md new file mode 100644 index 0000000..a66d63a --- /dev/null +++ b/Week 3/Encapsulation/README.md @@ -0,0 +1,14 @@ +# Encapsulation 🍡 + +### Task 🐧 + - Create a class callsed Information: + - Make private variables for name, age, and gender + - Create getters and setters for each of the private variables + - Create a boolean getter for if they are above the age of 21 + - Create two instances of Information with different names & genders & ages either above or below 21 + +### Requirements 🏫 +``` +1. A .java file +2. Print out if people are above the age of 21 with their name and gender +``` diff --git a/Week 3/Inheritance/README.md b/Week 3/Inheritance/README.md new file mode 100644 index 0000000..72f1e3d --- /dev/null +++ b/Week 3/Inheritance/README.md @@ -0,0 +1,21 @@ +# Inheritance 🍡 + +### Task 🐧 + - Create a class called Parent: + - Make an instance variable called last_name + - Make an instace variable called eye color + - Create a constructor and set all the instace varaiables to the parameters passed in + - Make a public method called `getLastName()` that returns the last name + + - Create a class called 'Child' that inherits (extends) Parent: + - Make an instance variable called first_name + - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) + - Create a method that returns the first and last name in a String + - Create a method that returns the eye color color of the parent + +### Requirements 🏫 +``` +1. A .java file +2. Prints the first and last name of the child +3. Prints the eye color of the parent +``` \ No newline at end of file diff --git a/Week 3/Lambdas/README.md b/Week 3/Lambdas/README.md new file mode 100644 index 0000000..4dfdb5f --- /dev/null +++ b/Week 3/Lambdas/README.md @@ -0,0 +1,13 @@ +# Lambdas 🍡 + +### Task 🐧 +Create a counter using Lambdas (Hint: Use class variables) + - Create a Consumer that takes in an integer + - Create a Supplier that returns the integer + - Create a Runnable that prints every positive integer out until the counter reaches the number by calling the other two lambdas + +### Requirements 🏫 +``` +1. A .java file +2. Every positive integer is printed out until the counter reaches the number +``` \ No newline at end of file diff --git a/Week 3/Non-Void Methods/README.md b/Week 3/Non-Void Methods/README.md new file mode 100644 index 0000000..3cf002f --- /dev/null +++ b/Week 3/Non-Void Methods/README.md @@ -0,0 +1,16 @@ +# Non-Void Methods 🍡 + +### Task 🐧 +Create code that completes the following tasks: + - Make a method that returns a string with " is friends with Albert" appended to the end of the string passed in to it + - Make a method that doubles the value you pass in + - Make a method the invertes the boolean that you pass in. + - Pass in your name to the first method + - Pass in your favorite team number to the second method + - Pass if true if you are an Optix Enjoyer + +### Requirements 🏫 +``` +1. A .java file +2. Prints your name, double your favorite team number, and true +``` \ No newline at end of file diff --git a/Week 3/Polymorphism/README.md b/Week 3/Polymorphism/README.md new file mode 100644 index 0000000..9fb38a6 --- /dev/null +++ b/Week 3/Polymorphism/README.md @@ -0,0 +1,17 @@ +# Polymorphism 🍡 + +### Task 🐧 + - Create a class called 'Calculator' + - Make the a method division that divides two ints & overload it to divide two doubles + - Make the a method multiplication that multiplies two ints + + - Create a class called 'SlowCalculator' that extends Calculator: + - Override the multiply method and use a loop to calculate the product of the two ints + +### Requirements 🏫 +``` +1. A .java file +2. Prints the exact qutient of 39 and 49 +3. Prints the rounded quotient of 37 and 49 +4. Prints the product of 37 and 49 +``` \ No newline at end of file diff --git a/Week 3/Void Methods/README.md b/Week 3/Void Methods/README.md new file mode 100644 index 0000000..32b663b --- /dev/null +++ b/Week 3/Void Methods/README.md @@ -0,0 +1,12 @@ +# Void Methods 🍡 + +### Task 🐧 +``` + - Make a void that will only print if the number you pass in (parameter) is greater than 10 + - Run this method with numbers 0.37 & 49 +``` +### Requirements 🏫 +``` +1. A .java file +2. Prints false and true on two different lines +``` \ No newline at end of file From 829489f4dffb90564a5648d332325685f692ebf2 Mon Sep 17 00:00:00 2001 From: rohin Date: Sun, 25 Sep 2022 06:17:33 -0700 Subject: [PATCH 14/21] =?UTF-8?q?week=203=20homeowrk=20=F0=9F=98=8D?= =?UTF-8?q?=F0=9F=98=8D=F0=9F=98=8D=F0=9F=98=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Week 3/Homework/README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Week 3/Homework/README.md diff --git a/Week 3/Homework/README.md b/Week 3/Homework/README.md new file mode 100644 index 0000000..12a810d --- /dev/null +++ b/Week 3/Homework/README.md @@ -0,0 +1,36 @@ +# Week 3 Homework 🍡 + +### Task 🐧 +Create a mock FRC robot πŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯Ά + +Create a class called Motor + - Make a constructor for the port number of the motor + - Includes `set()`, `get()`, and `stop()` methods + - `set()` sets the speed of the motor + - `get()` returns the speed of the motor + - `stop()` sets the speed of the motor to 0 + +Create a class called Shooter + - Encapsulate two motors with ports 25 and 26 (Hint: Private object but public methods) + - Create a method to set the speed of both motors + +Create a class called Shoot + - Create an instance variable for the Shooter class & set it to the parameter of the constructor + - Includes `initialize()`, `execute()`, and `end()` methods + - `initialize()` sets the speed of the shooter to 0 & prints "Shooter initialized" + - `execute()` sets the speed of the shooter to 1 & prints "Shooting" + - `end()` sets the speed of the shooter to 0 & prints "Shooter stopped" + +Create a class called Robot + - Declare the Shooter and Shoot objects + - Create a method called `teleopInit()` that calls the `initialize()` method of the Shoot object + - Create a method called `teleopPeriodic()` that calls the `execute()` method of the Shoot object IF the user enters the key "A" in the terminal + - Create a method called `teleopEnd()` that calls the `end()` method of the Shoot object + +### Requirements 🏫 +``` +1. A .java file +2. Prints the exact qutient of 39 and 49 +3. Prints the rounded quotient of 37 and 49 +4. Prints the product of 37 and 49 +``` \ No newline at end of file From 4846cee8f99aa265e304a085f05bdd55311fc354 Mon Sep 17 00:00:00 2001 From: rohin Date: Mon, 26 Sep 2022 01:32:06 -0700 Subject: [PATCH 15/21] fix homework --- Week 3/Homework/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Week 3/Homework/README.md b/Week 3/Homework/README.md index 12a810d..602fc15 100644 --- a/Week 3/Homework/README.md +++ b/Week 3/Homework/README.md @@ -24,13 +24,14 @@ Create a class called Shoot Create a class called Robot - Declare the Shooter and Shoot objects - Create a method called `teleopInit()` that calls the `initialize()` method of the Shoot object - - Create a method called `teleopPeriodic()` that calls the `execute()` method of the Shoot object IF the user enters the key "A" in the terminal + - Create a method called `teleopPeriodic()` that repeatedly calls the `execute()` method of the Shoot object IF the user enters the key "A" in the terminal + - If the user enters the key "q", exit `teleopPeriodic()` - Create a method called `teleopEnd()` that calls the `end()` method of the Shoot object ### Requirements 🏫 ``` -1. A .java file -2. Prints the exact qutient of 39 and 49 -3. Prints the rounded quotient of 37 and 49 -4. Prints the product of 37 and 49 + 1. A .java file + 2. Prints "Shooter initialized" when the robot is turned on + 3. Prints "Shooting" when the user enters the key "A" in the terminal + 4. Prints "Shooter stopped" when the user enters "q" in the terminal ``` \ No newline at end of file From 1b9b71626a9589bd2f8c974192e0ef221579cd7c Mon Sep 17 00:00:00 2001 From: NoahSimon8 Date: Sat, 15 Jul 2023 17:45:59 -0700 Subject: [PATCH 16/21] Removed Robot Homework --- Week 3/Homework/README.md | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Week 3/Homework/README.md diff --git a/Week 3/Homework/README.md b/Week 3/Homework/README.md deleted file mode 100644 index 602fc15..0000000 --- a/Week 3/Homework/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Week 3 Homework 🍡 - -### Task 🐧 -Create a mock FRC robot πŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯ΆπŸ₯Ά - -Create a class called Motor - - Make a constructor for the port number of the motor - - Includes `set()`, `get()`, and `stop()` methods - - `set()` sets the speed of the motor - - `get()` returns the speed of the motor - - `stop()` sets the speed of the motor to 0 - -Create a class called Shooter - - Encapsulate two motors with ports 25 and 26 (Hint: Private object but public methods) - - Create a method to set the speed of both motors - -Create a class called Shoot - - Create an instance variable for the Shooter class & set it to the parameter of the constructor - - Includes `initialize()`, `execute()`, and `end()` methods - - `initialize()` sets the speed of the shooter to 0 & prints "Shooter initialized" - - `execute()` sets the speed of the shooter to 1 & prints "Shooting" - - `end()` sets the speed of the shooter to 0 & prints "Shooter stopped" - -Create a class called Robot - - Declare the Shooter and Shoot objects - - Create a method called `teleopInit()` that calls the `initialize()` method of the Shoot object - - Create a method called `teleopPeriodic()` that repeatedly calls the `execute()` method of the Shoot object IF the user enters the key "A" in the terminal - - If the user enters the key "q", exit `teleopPeriodic()` - - Create a method called `teleopEnd()` that calls the `end()` method of the Shoot object - -### Requirements 🏫 -``` - 1. A .java file - 2. Prints "Shooter initialized" when the robot is turned on - 3. Prints "Shooting" when the user enters the key "A" in the terminal - 4. Prints "Shooter stopped" when the user enters "q" in the terminal -``` \ No newline at end of file From 8d7e739690537f9d97b7ca47a6b1ab8d48799d89 Mon Sep 17 00:00:00 2001 From: NoahSimon8 Date: Sat, 15 Jul 2023 17:49:38 -0700 Subject: [PATCH 17/21] Impots and inputs --- Week 3/Imports and Inputs/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Week 3/Imports and Inputs/README.md diff --git a/Week 3/Imports and Inputs/README.md b/Week 3/Imports and Inputs/README.md new file mode 100644 index 0000000..25800c1 --- /dev/null +++ b/Week 3/Imports and Inputs/README.md @@ -0,0 +1,16 @@ +# Imports 🍡 + +### Task 🐧 +Create a number guessing game with the following requirements! (Import Scanner and Math) + - Generate a random number between 1 and 100 + - Ask the user to guess the number + - If the user guesses the number, print "You guessed the number!" + - If the user guesses too high, print "Too high!" + - If the user guesses too low, print "Too low!" + - If the user guesses the number more than 5 times, print "You lose!" + +### Requirements 🏫 +``` +1. A .java file +2. The guessing game & result of the guessing game +``` From 854f98f155495b4bbad8482d8f4dbb5e5a3aa940 Mon Sep 17 00:00:00 2001 From: NoahSimon8 Date: Mon, 7 Oct 2024 15:20:46 -0700 Subject: [PATCH 18/21] updated week 3 --- Week 3/Arrays/README.txt | 16 ++++++++++++++++ Week 3/Imports and Inputs/README.md | 16 ---------------- Week 3/Lambdas/README.md | 13 ------------- 3 files changed, 16 insertions(+), 29 deletions(-) create mode 100644 Week 3/Arrays/README.txt delete mode 100644 Week 3/Imports and Inputs/README.md delete mode 100644 Week 3/Lambdas/README.md diff --git a/Week 3/Arrays/README.txt b/Week 3/Arrays/README.txt new file mode 100644 index 0000000..a732edc --- /dev/null +++ b/Week 3/Arrays/README.txt @@ -0,0 +1,16 @@ +# Arrays 🍡 + +### Task 🐧 +Create code that consists of an array with the following elements: + - An element containing the name of your department + - An element contianing the name of the oldest person in the world + - An element contianing the name of the Rapid React world champion alliance captains + - An element containing the name of the 2019 FRC game + + - Then print each element, from last to first. + +### Requirements 🏫 +``` +1. A .java file +2. Creates an array and prints the elements as specified +``` diff --git a/Week 3/Imports and Inputs/README.md b/Week 3/Imports and Inputs/README.md deleted file mode 100644 index 25800c1..0000000 --- a/Week 3/Imports and Inputs/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Imports 🍡 - -### Task 🐧 -Create a number guessing game with the following requirements! (Import Scanner and Math) - - Generate a random number between 1 and 100 - - Ask the user to guess the number - - If the user guesses the number, print "You guessed the number!" - - If the user guesses too high, print "Too high!" - - If the user guesses too low, print "Too low!" - - If the user guesses the number more than 5 times, print "You lose!" - -### Requirements 🏫 -``` -1. A .java file -2. The guessing game & result of the guessing game -``` diff --git a/Week 3/Lambdas/README.md b/Week 3/Lambdas/README.md deleted file mode 100644 index 4dfdb5f..0000000 --- a/Week 3/Lambdas/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Lambdas 🍡 - -### Task 🐧 -Create a counter using Lambdas (Hint: Use class variables) - - Create a Consumer that takes in an integer - - Create a Supplier that returns the integer - - Create a Runnable that prints every positive integer out until the counter reaches the number by calling the other two lambdas - -### Requirements 🏫 -``` -1. A .java file -2. Every positive integer is printed out until the counter reaches the number -``` \ No newline at end of file From 8db1866e5b5f853389056df36ccb47697046e424 Mon Sep 17 00:00:00 2001 From: NoahSimon8 Date: Mon, 7 Oct 2024 15:23:22 -0700 Subject: [PATCH 19/21] removed methods from week 3 --- Week 3/Non-Void Methods/README.md | 16 ---------------- Week 3/Void Methods/README.md | 12 ------------ 2 files changed, 28 deletions(-) delete mode 100644 Week 3/Non-Void Methods/README.md delete mode 100644 Week 3/Void Methods/README.md diff --git a/Week 3/Non-Void Methods/README.md b/Week 3/Non-Void Methods/README.md deleted file mode 100644 index 3cf002f..0000000 --- a/Week 3/Non-Void Methods/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Non-Void Methods 🍡 - -### Task 🐧 -Create code that completes the following tasks: - - Make a method that returns a string with " is friends with Albert" appended to the end of the string passed in to it - - Make a method that doubles the value you pass in - - Make a method the invertes the boolean that you pass in. - - Pass in your name to the first method - - Pass in your favorite team number to the second method - - Pass if true if you are an Optix Enjoyer - -### Requirements 🏫 -``` -1. A .java file -2. Prints your name, double your favorite team number, and true -``` \ No newline at end of file diff --git a/Week 3/Void Methods/README.md b/Week 3/Void Methods/README.md deleted file mode 100644 index 32b663b..0000000 --- a/Week 3/Void Methods/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# Void Methods 🍡 - -### Task 🐧 -``` - - Make a void that will only print if the number you pass in (parameter) is greater than 10 - - Run this method with numbers 0.37 & 49 -``` -### Requirements 🏫 -``` -1. A .java file -2. Prints false and true on two different lines -``` \ No newline at end of file From f5250cad9fc299a436e14bbed3da04f68dc13898 Mon Sep 17 00:00:00 2001 From: Dhyan Soni Date: Fri, 25 Oct 2024 08:52:24 -0700 Subject: [PATCH 20/21] Commiting prior weeks of training --- {Week 3 => Week3}/Abstraction/README.md | 0 Week3/Arrays/Arrays.java | 24 +++++++++++ {Week 3 => Week3}/Arrays/README.txt | 0 Week3/Classes & Objects/Me.java | 21 +++++++++ Week3/Classes & Objects/Pokemon.java | 23 ++++++++++ {Week 3 => Week3}/Classes & Objects/README.md | 0 {Week 3 => Week3}/Encapsulation/README.md | 0 Week3/Inheritance/Child.java | 43 +++++++++++++++++++ Week3/Inheritance/Main.java | 31 +++++++++++++ Week3/Inheritance/Parent.java | 37 ++++++++++++++++ {Week 3 => Week3}/Inheritance/README.md | 0 {Week 3 => Week3}/Polymorphism/README.md | 0 12 files changed, 179 insertions(+) rename {Week 3 => Week3}/Abstraction/README.md (100%) create mode 100644 Week3/Arrays/Arrays.java rename {Week 3 => Week3}/Arrays/README.txt (100%) create mode 100644 Week3/Classes & Objects/Me.java create mode 100644 Week3/Classes & Objects/Pokemon.java rename {Week 3 => Week3}/Classes & Objects/README.md (100%) rename {Week 3 => Week3}/Encapsulation/README.md (100%) create mode 100644 Week3/Inheritance/Child.java create mode 100644 Week3/Inheritance/Main.java create mode 100644 Week3/Inheritance/Parent.java rename {Week 3 => Week3}/Inheritance/README.md (100%) rename {Week 3 => Week3}/Polymorphism/README.md (100%) diff --git a/Week 3/Abstraction/README.md b/Week3/Abstraction/README.md similarity index 100% rename from Week 3/Abstraction/README.md rename to Week3/Abstraction/README.md diff --git a/Week3/Arrays/Arrays.java b/Week3/Arrays/Arrays.java new file mode 100644 index 0000000..f7c8f5b --- /dev/null +++ b/Week3/Arrays/Arrays.java @@ -0,0 +1,24 @@ +// # Arrays 🍡 + +// ### Task 🐧 +// Create code that consists of an array with the following elements: +// - An element containing the name of your department +// - An element contianing the name of the oldest person in the world +// - An element contianing the name of the Rapid React world champion alliance captains +// - An element containing the name of the 2019 FRC game + +// - Then print each element, from last to first. + +// ### Requirements 🏫 +// ``` +// 1. A .java file +// 2. Creates an array and prints the elements as specified +// ``` +public class Arrays { + public static void main(String[] args) { + String[] robotics_array = {"software", "Tomiko", "Ferradermis", "Destination: Deep Space"}; + for (int i = 0; i < 4; i++) { + System.out.println(robotics_array[i]); + } + } +} \ No newline at end of file diff --git a/Week 3/Arrays/README.txt b/Week3/Arrays/README.txt similarity index 100% rename from Week 3/Arrays/README.txt rename to Week3/Arrays/README.txt diff --git a/Week3/Classes & Objects/Me.java b/Week3/Classes & Objects/Me.java new file mode 100644 index 0000000..4b9bb8f --- /dev/null +++ b/Week3/Classes & Objects/Me.java @@ -0,0 +1,21 @@ +public class Me { + String name; + int age; + + Me(String name, int age){ + this.name = name; + this.age = age; + } + + String getName(){ + return name; + } + + int getAge(){ + return age; + } + public static void main(String[] args) { + Me dhyan = new Me("dhyan", 14); + System.out.println("Name: " + dhyan.getName() + ", Age: " + dhyan.getAge()); + } +} diff --git a/Week3/Classes & Objects/Pokemon.java b/Week3/Classes & Objects/Pokemon.java new file mode 100644 index 0000000..f19d419 --- /dev/null +++ b/Week3/Classes & Objects/Pokemon.java @@ -0,0 +1,23 @@ +public class Pokemon { + String name; + int level; + + Pokemon(){ + level = 1; // default value + } + + Pokemon(String pName, int pLevel){ + name = pName; + level = pLevel; + } + + void attack(){ + System.out.println(name + " attack!"); + } + public static void main(String[] args) { + + Pokemon p1 = new Pokemon("andrew", "0"); + + System.out.println(p1.level); + } +} diff --git a/Week 3/Classes & Objects/README.md b/Week3/Classes & Objects/README.md similarity index 100% rename from Week 3/Classes & Objects/README.md rename to Week3/Classes & Objects/README.md diff --git a/Week 3/Encapsulation/README.md b/Week3/Encapsulation/README.md similarity index 100% rename from Week 3/Encapsulation/README.md rename to Week3/Encapsulation/README.md diff --git a/Week3/Inheritance/Child.java b/Week3/Inheritance/Child.java new file mode 100644 index 0000000..d133f4e --- /dev/null +++ b/Week3/Inheritance/Child.java @@ -0,0 +1,43 @@ +// # Inheritance 🍡 + +// ### Task 🐧 +// - Create a class called Parent: +// - Make an instance variable called last_name +// - Make an instace variable called eye color +// - Create a constructor and set all the instace varaiables to the parameters passed in +// - Make a public method called `getLastName()` that returns the last name + +// - Create a class called 'Child' that inherits (extends) Parent: +// - Make an instance variable called first_name +// - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) +// - Create a method that returns the first and last name in a String +// - Create a method that returns the eye color color of the parent + +// ### Requirements 🏫 +// ``` +// 1. A .java file +// 2. Prints the first and last name of the child +// 3. Prints the eye color of the parent +// ``` +package JavaTraining2024.Week3.Inheritance; + +public class Child extends Parent{ + String first_name; + String last_name; + String eye_color; + + public Child(String first_name, String last_name, String eye_color){ + super(last_name, eye_color); + this.last_name = last_name; + this.first_name = first_name; + this.eye_color = eye_color; + } + + public String getFullName(){ + return first_name + last_name; + } + + String getEyeColor(){ + return eye_color; + } +} \ No newline at end of file diff --git a/Week3/Inheritance/Main.java b/Week3/Inheritance/Main.java new file mode 100644 index 0000000..6ad7a7c --- /dev/null +++ b/Week3/Inheritance/Main.java @@ -0,0 +1,31 @@ + +// # Inheritance 🍡 + +// ### Task 🐧 +// - Create a class called Parent: +// - Make an instance variable called last_name +// - Make an instace variable called eye color +// - Create a constructor and set all the instace varaiables to the parameters passed in +// - Make a public method called `getLastName()` that returns the last name + +// - Create a class called 'Child' that inherits (extends) Parent: +// - Make an instance variable called first_name +// - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) +// - Create a method that returns the first and last name in a String +// - Create a method that returns the eye color color of the parent + +// ### Requirements 🏫 +// ``` +// 1. A .java file +// 2. Prints the first and last name of the child +// 3. Prints the eye color of the parent +// ``` +package JavaTraining2024.Week3.Inheritance; + + +public class Main { + public static void main(String[] args){ + Child dhyan = new Child("dhyan", "soni", "brown"); + System.out.println(dhyan.getEyeColor()); + } +} \ No newline at end of file diff --git a/Week3/Inheritance/Parent.java b/Week3/Inheritance/Parent.java new file mode 100644 index 0000000..54f04d6 --- /dev/null +++ b/Week3/Inheritance/Parent.java @@ -0,0 +1,37 @@ +// # Inheritance 🍡 + +// ### Task 🐧 +// - Create a class called Parent: +// - Make an instance variable called last_name +// - Make an instace variable called eye color +// - Create a constructor and set all the instace varaiables to the parameters passed in +// - Make a public method called `getLastName()` that returns the last name + +// - Create a class called 'Child' that inherits (extends) Parent: +// - Make an instance variable called first_name +// - Make a constructor that first, sets first_name, and second, calls the constructor of Parent (Make sure to pass in the last name and eye color) +// - Create a method that returns the first and last name in a String +// - Create a method that returns the eye color color of the parent + +// ### Requirements 🏫 +// ``` +// 1. A .java file +// 2. Prints the first and last name of the child +// 3. Prints the eye color of the parent +// ``` +package JavaTraining2024.Week3.Inheritance; + +public class Parent { + String last_name; + String eye_color; + + Parent(String last_name, String eye_color){ + this.last_name = last_name; + this.eye_color = eye_color; + } + + String getLastName(){ + return last_name; + } +} + diff --git a/Week 3/Inheritance/README.md b/Week3/Inheritance/README.md similarity index 100% rename from Week 3/Inheritance/README.md rename to Week3/Inheritance/README.md diff --git a/Week 3/Polymorphism/README.md b/Week3/Polymorphism/README.md similarity index 100% rename from Week 3/Polymorphism/README.md rename to Week3/Polymorphism/README.md From 579a7d71b5dbfd03ac8b1e293202f962431f5fc1 Mon Sep 17 00:00:00 2001 From: Dhyan Soni Date: Fri, 25 Oct 2024 09:11:51 -0700 Subject: [PATCH 21/21] pokemon project --- Week3/Project/Charizard.java | 24 +++++++++++++++++++++++ Week3/Project/Main.java | 19 ++++++++++++++++++ Week3/Project/Pikachu.java | 24 +++++++++++++++++++++++ Week3/Project/Pokemon.java | 37 ++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 Week3/Project/Charizard.java create mode 100644 Week3/Project/Main.java create mode 100644 Week3/Project/Pikachu.java create mode 100644 Week3/Project/Pokemon.java diff --git a/Week3/Project/Charizard.java b/Week3/Project/Charizard.java new file mode 100644 index 0000000..2a35676 --- /dev/null +++ b/Week3/Project/Charizard.java @@ -0,0 +1,24 @@ +package JavaTraining2024.Week3.Project; + +public class Charizard extends Pokemon{ + int health; + String name; + + // overiding the attack class + @Override + public void attack(Pokemon opposite_pokemon){ + take_damage(5); + } + + // setting up default values + Charizard() { + super(20, "Charizard"); + } + + // non default constructor so you can set up values + Charizard(int health, String name) { + super(health, name); + this.health = health; + this.name = name; + } +} diff --git a/Week3/Project/Main.java b/Week3/Project/Main.java new file mode 100644 index 0000000..88e20ba --- /dev/null +++ b/Week3/Project/Main.java @@ -0,0 +1,19 @@ +package JavaTraining2024.Week3.Project; + +public class Main { + public static void main(String[] args) { + Pikachu pikachu = new Pikachu(40, "Pikachu"); + Charizard charizard = new Charizard(30, "AwesomeCharizard"); + + while (!pikachu.getIsFainted() && !charizard.getIsFainted()){ + pikachu.attack(charizard); + charizard.attack(pikachu); + } + if (pikachu.getIsFainted()){ + System.out.println(pikachu.getName() + " fainted :("); + } + if (charizard.getIsFainted()){ + System.out.println(charizard.getName() + " fainted :("); + } + } +} diff --git a/Week3/Project/Pikachu.java b/Week3/Project/Pikachu.java new file mode 100644 index 0000000..34fcd28 --- /dev/null +++ b/Week3/Project/Pikachu.java @@ -0,0 +1,24 @@ +package JavaTraining2024.Week3.Project; + +public class Pikachu extends Pokemon{ + int health; + String name; + + // overiding the attack class + @Override + public void attack(Pokemon opposite_pokemon){ + take_damage(5); + } + + // setting up default values + Pikachu() { + super(20, "Pikachu"); + } + + // non default constructor so you can set up values + Pikachu(int health, String name) { + super(health, name); + this.health = health; + this.name = name; + } +} diff --git a/Week3/Project/Pokemon.java b/Week3/Project/Pokemon.java new file mode 100644 index 0000000..4a01528 --- /dev/null +++ b/Week3/Project/Pokemon.java @@ -0,0 +1,37 @@ +package JavaTraining2024.Week3.Project; + +abstract class Pokemon { + // Private variables as per ReadMe (encapuslation) + private int health; + private String name; + + // non-default constructor enabling user to input a health and name value + Pokemon(int health, String name){ + this.health = health; + this.name = name; + } + + // method to calculate damage taken + public void take_damage(int damage){ + health = health - damage; + } + + // method to find out if the pokemon is fainted or not + public boolean getIsFainted(){ + if (health <= 0) { + return true; + } + else { + return false; + } + } + + // abstract method to be used when this class is used in another class and supposed to be overridden + public abstract void attack(Pokemon opposite_pokemon); + + // simple method to get the name of the pokemon + public String getName(){ + return name; + } + +}