From c00f8cbaea92c7c65c1ca4e629461146ce287e06 Mon Sep 17 00:00:00 2001 From: Rohin Sood Date: Mon, 4 Jul 2022 13:03:21 -0700 Subject: [PATCH 01/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] 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/36] =?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/36] =?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/36] 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/36] 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/36] 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/36] 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/36] 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 17bab6728fdc0c1673e1786fc1ad328e78dad020 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 10 Oct 2024 18:39:02 -0700 Subject: [PATCH 20/36] it kinda works dw about it --- {Week 3 => Week3}/Abstraction/README.md | 0 Week3/Arrays/Array.java | 7 +++++++ {Week 3 => Week3}/Arrays/README.txt | 0 {Week 3 => Week3}/Classes & Objects/README.md | 0 {Week 3 => Week3}/Encapsulation/README.md | 0 {Week 3 => Week3}/Inheritance/README.md | 0 {Week 3 => Week3}/Polymorphism/README.md | 0 7 files changed, 7 insertions(+) rename {Week 3 => Week3}/Abstraction/README.md (100%) create mode 100644 Week3/Arrays/Array.java rename {Week 3 => Week3}/Arrays/README.txt (100%) rename {Week 3 => Week3}/Classes & Objects/README.md (100%) rename {Week 3 => Week3}/Encapsulation/README.md (100%) 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/Array.java b/Week3/Arrays/Array.java new file mode 100644 index 0000000..10aa284 --- /dev/null +++ b/Week3/Arrays/Array.java @@ -0,0 +1,7 @@ +public class Array { + public static void main(String[] args) + { + System.out.println("sus"); + } +} + 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/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/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 bb802d7c1fc429bde5df9a570171f023da855d64 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 17 Oct 2024 16:53:08 -0700 Subject: [PATCH 21/36] created class homework --- Week3/Classes&Objects/Pokemon.java | 18 ++++++++++++++++++ .../README.md | 0 2 files changed, 18 insertions(+) create mode 100644 Week3/Classes&Objects/Pokemon.java rename Week3/{Classes & Objects => Classes&Objects}/README.md (100%) diff --git a/Week3/Classes&Objects/Pokemon.java b/Week3/Classes&Objects/Pokemon.java new file mode 100644 index 0000000..1fa97ba --- /dev/null +++ b/Week3/Classes&Objects/Pokemon.java @@ -0,0 +1,18 @@ +public class Pokemon { + String name; + int level; + + void attack(){ + System.out.print(name + "attack!"); + } + + public static void main(String[] args) { + + Pokemon p1 = new Pokemon(); + p1.name = "Pikachu"; + p1.level = 100; + + System.out.println(p1.name + " " + p1.level); + p1.attack(); + } +} diff --git a/Week3/Classes & Objects/README.md b/Week3/Classes&Objects/README.md similarity index 100% rename from Week3/Classes & Objects/README.md rename to Week3/Classes&Objects/README.md From 99e8115715395b9d2675199a03edaafca0cd2a05 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 17 Oct 2024 17:20:43 -0700 Subject: [PATCH 22/36] did the array homework on time --- Week3/Arrays/Array.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Week3/Arrays/Array.java b/Week3/Arrays/Array.java index 10aa284..3f132ba 100644 --- a/Week3/Arrays/Array.java +++ b/Week3/Arrays/Array.java @@ -1,7 +1,10 @@ public class Array { - public static void main(String[] args) - { - System.out.println("sus"); - } + public static void main(String[] args) { + String[] randomRoboticInformation = {"Software", "blah blah blah"}; + + for (int i = 0; i < randomRoboticInformation.length; i++) { + System.out.println(randomRoboticInformation[i]); + } + } } From f75279ce53a5f6809b1e5404fed07fb1619e1fb5 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 17 Oct 2024 17:35:16 -0700 Subject: [PATCH 23/36] finished class homework --- Week3/Classes&Objects/Me.java | 21 +++++++++++++++++++++ Week3/Classes&Objects/Pokemon.java | 24 ++++++++++++++++++------ 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 Week3/Classes&Objects/Me.java diff --git a/Week3/Classes&Objects/Me.java b/Week3/Classes&Objects/Me.java new file mode 100644 index 0000000..1849d80 --- /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; + } + void name() { + System.out.println(this.name); + } + void age() { + System.out.println(this.age); + } + + public static void main(String[] args) { + Me justin = new Me("Justin", 17); + justin.name(); + justin.age(); + } +} diff --git a/Week3/Classes&Objects/Pokemon.java b/Week3/Classes&Objects/Pokemon.java index 1fa97ba..ee9ab4e 100644 --- a/Week3/Classes&Objects/Pokemon.java +++ b/Week3/Classes&Objects/Pokemon.java @@ -2,17 +2,29 @@ public class Pokemon { String name; int level; + + Pokemon(){ + level = 1; + } + + Pokemon(String pName, int pLevel){ + // Use variables defined in class (at top of page) rather than local variables (this statements) + this.name = pName; + this.level = pLevel; + } + void attack(){ - System.out.print(name + "attack!"); + System.out.println(name + "attack!"); } public static void main(String[] args) { - Pokemon p1 = new Pokemon(); - p1.name = "Pikachu"; - p1.level = 100; + Pokemon p1 = new Pokemon("Pikachu", 15); - System.out.println(p1.name + " " + p1.level); - p1.attack(); + System.out.print(p1.name + "\nLevel:" + p1.level); + + Pokemon p2 = new Pokemon("Vaporeon", 69); + + p2.attack(); } } From 8f94d8a99ced1ceed75b60e94ef5dfb69f57be05 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 17 Oct 2024 17:35:25 -0700 Subject: [PATCH 24/36] inheritance activitiy start --- Week3/Inheritance/Vehicle.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Week3/Inheritance/Vehicle.java diff --git a/Week3/Inheritance/Vehicle.java b/Week3/Inheritance/Vehicle.java new file mode 100644 index 0000000..207ab25 --- /dev/null +++ b/Week3/Inheritance/Vehicle.java @@ -0,0 +1,25 @@ +package Week3.Inheritance; + +public class Vehicle { + double speed; + + void go() { + System.out.println("This vehicle is moving!"); + } + + void stop() { + System.out.println("This vehicle is stopped!"); + } + public static void main(String[] args) { + Car ferrari = new Car(); + ferrari.go(); + } +} + +class Car extends Vehicle { + +} + +class Bicycle extends Vehicle { + +} \ No newline at end of file From fd95cd83d1a84a70592867ed326c8e0f2de4ac54 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 08:54:50 -0700 Subject: [PATCH 25/36] did the inheritance homework --- Week3/Inheritance/Main.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Week3/Inheritance/Main.java diff --git a/Week3/Inheritance/Main.java b/Week3/Inheritance/Main.java new file mode 100644 index 0000000..540e98f --- /dev/null +++ b/Week3/Inheritance/Main.java @@ -0,0 +1,33 @@ +public class Main { + + public static void main(String[] args) { + Child Jim = new Child("Jim"); + Jim.getLastName(); + Jim.parentEyeColor(); + } +} + +class Parent { + String last_name = "Smithson"; + String eye_color = "Blue"; + + void getLastName() { + System.out.println("This person's last name is " + this.last_name); + } +} + +class Child extends Parent { + String first_name; + + Child(String first_name) { + this.first_name = first_name; + } + + void getFullName() { + System.out.println("This is" + first_name + " his last name is " + last_name + "."); + } + + void parentEyeColor() { + System.out.println("The parent has " + eye_color + " eyes."); + } +} \ No newline at end of file From 8cf904412aa16c5443d53a956ded81e1b8fc0c65 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 16:00:26 -0700 Subject: [PATCH 26/36] fixed issue --- Week3/Inheritance/Vehicle.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Week3/Inheritance/Vehicle.java b/Week3/Inheritance/Vehicle.java index 207ab25..770d1fc 100644 --- a/Week3/Inheritance/Vehicle.java +++ b/Week3/Inheritance/Vehicle.java @@ -1,5 +1,3 @@ -package Week3.Inheritance; - public class Vehicle { double speed; From 982c345ece543ff454ec2f317fd4cd89dd06ed7d Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 16:11:29 -0700 Subject: [PATCH 27/36] fixed mistake --- Week3/Inheritance/Main.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Week3/Inheritance/Main.java b/Week3/Inheritance/Main.java index 540e98f..bb33acc 100644 --- a/Week3/Inheritance/Main.java +++ b/Week3/Inheritance/Main.java @@ -1,16 +1,20 @@ public class Main { public static void main(String[] args) { - Child Jim = new Child("Jim"); + Child Jim = new Child("Jim", "Smithson", "blue"); Jim.getLastName(); Jim.parentEyeColor(); } } class Parent { - String last_name = "Smithson"; - String eye_color = "Blue"; + String last_name; + String eye_color; + Parent(String last_name, String eyeColor) { + this.last_name = last_name; + this.eye_color = eyeColor; + } void getLastName() { System.out.println("This person's last name is " + this.last_name); } @@ -19,7 +23,8 @@ void getLastName() { class Child extends Parent { String first_name; - Child(String first_name) { + Child(String first_name, String lastName, String eyeColor) { + super(lastName, eyeColor); this.first_name = first_name; } @@ -28,6 +33,6 @@ void getFullName() { } void parentEyeColor() { - System.out.println("The parent has " + eye_color + " eyes."); + System.out.println("The parent has " + super.eye_color + " eyes."); } } \ No newline at end of file From 24f68826beadfe4077d9ad8e5d2e787224d1f915 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 17:10:05 -0700 Subject: [PATCH 28/36] finish the abstraction homework --- Week3/Abstraction/Shirt.java | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Week3/Abstraction/Shirt.java diff --git a/Week3/Abstraction/Shirt.java b/Week3/Abstraction/Shirt.java new file mode 100644 index 0000000..cb0cf3a --- /dev/null +++ b/Week3/Abstraction/Shirt.java @@ -0,0 +1,52 @@ +// Abstract means that you can't create a object of this class, only it's children +public abstract class Shirt { + String color; + Shirt(String color) { + this.color = color; + } + + public String getColor() { + return this.color; + } + + abstract void getDescription(); + + public static void main(String[] args) { + Shirt[] myShirt = {new T_Shirt("Blue", "XL:", 29.99), new Jacket("Black", "Adidas", 49.99)}; + for (int i = 0; i < myShirt.length; i++) { + myShirt[i].getDescription(); + } + } +} + +class T_Shirt extends Shirt { + String size; + double price; + + T_Shirt(String color, String size, double price) { + super(color); + this.size = size; + this.price = price; + } + + @Override + void getDescription() { + System.out.println("\n\nT-Shirt:\nColor: " + color + "\nSize: " + size + "\nPrice: $" + price); + } +} + +class Jacket extends Shirt { + double price; + String brand; + + Jacket(String color, String brand, double price) { + super(color); + this.brand = brand; + this.price = price; + } + + @Override + void getDescription() { + System.out.println("\n\nJacket:\nColor: " + color + "\nBraand: " + brand + "\nPrice: $" + price); + } +} \ No newline at end of file From 5e1cdf6a3db6ae2e26f9d99d9d99f22c28bad951 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 17:11:01 -0700 Subject: [PATCH 29/36] polymorphism homework and practuce done --- Week3/Polymorphism/Calculator.java | 33 ++++++++++++++++++++++++++++++ Week3/Polymorphism/Sample.java | 28 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Week3/Polymorphism/Calculator.java create mode 100644 Week3/Polymorphism/Sample.java diff --git a/Week3/Polymorphism/Calculator.java b/Week3/Polymorphism/Calculator.java new file mode 100644 index 0000000..95bc1a5 --- /dev/null +++ b/Week3/Polymorphism/Calculator.java @@ -0,0 +1,33 @@ +public class Calculator { + public Integer division(int num1, int num2) { + return num1/num2; + } + + public double division(double num1, double num2) { + return num1/num2; + } + + public Integer multiply(int num1, int num2) { + return num1*num2; + } + + public static void main(String[] args) { + Calculator jim = new SlowCalculator(); + jim.multiply(10, 4); + jim.division(4.5, 1.5); + jim.division(4, 2); + } +} + +class SlowCalculator extends Calculator { + int num3; + + public Integer multiply(int num1, int num2) { + this.num3 = 0; + for (int i = 0; i < num2; i++) { + System.out.println(num3); + num3 = num1 + num3; + } + return this.num3; + } +} diff --git a/Week3/Polymorphism/Sample.java b/Week3/Polymorphism/Sample.java new file mode 100644 index 0000000..d277a94 --- /dev/null +++ b/Week3/Polymorphism/Sample.java @@ -0,0 +1,28 @@ +public class Sample { + String ice; + Sample(String ice) { + this.ice = ice; + } + + void saySomething() { + System.out.println("HEY!"); + } + + public static void main(String[] args) { + Sample[] bob = {new Polymorphism("ice"), new Sample("ice"), new Polymorphism("ice"), new Sample("Bob")}; + for (int i = 0; i < bob.length; i++) { + bob[i].saySomething(); + } + } +} + +class Polymorphism extends Sample { + Polymorphism(String ice) { + super(ice); + } + + @Override + void saySomething() { + System.out.println("Hey?"); + } +} From da94ca31f8fee755dec2fae2ad45788d5c4e71e6 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 17:13:24 -0700 Subject: [PATCH 30/36] added public and private to promote better readability --- Week3/Abstraction/Shirt.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Week3/Abstraction/Shirt.java b/Week3/Abstraction/Shirt.java index cb0cf3a..b09cbaa 100644 --- a/Week3/Abstraction/Shirt.java +++ b/Week3/Abstraction/Shirt.java @@ -1,7 +1,8 @@ // Abstract means that you can't create a object of this class, only it's children public abstract class Shirt { - String color; - Shirt(String color) { + public String color; + + public Shirt(String color) { this.color = color; } @@ -20,33 +21,33 @@ public static void main(String[] args) { } class T_Shirt extends Shirt { - String size; - double price; + private String size; + private double price; - T_Shirt(String color, String size, double price) { + public T_Shirt(String color, String size, double price) { super(color); this.size = size; this.price = price; } @Override - void getDescription() { + public void getDescription() { System.out.println("\n\nT-Shirt:\nColor: " + color + "\nSize: " + size + "\nPrice: $" + price); } } class Jacket extends Shirt { - double price; - String brand; + private double price; + private String brand; - Jacket(String color, String brand, double price) { + public Jacket(String color, String brand, double price) { super(color); this.brand = brand; this.price = price; } @Override - void getDescription() { + public void getDescription() { System.out.println("\n\nJacket:\nColor: " + color + "\nBraand: " + brand + "\nPrice: $" + price); } } \ No newline at end of file From a4d0ba653ba04d01e03b670c3eac27a1df0b5536 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 17:27:11 -0700 Subject: [PATCH 31/36] finished encapsulation homework --- Week3/Encapsulation/Information.java | 59 ++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Week3/Encapsulation/Information.java diff --git a/Week3/Encapsulation/Information.java b/Week3/Encapsulation/Information.java new file mode 100644 index 0000000..8ebeae1 --- /dev/null +++ b/Week3/Encapsulation/Information.java @@ -0,0 +1,59 @@ +public class Information { + // Private means variable cannot be accessed outside of class + private String name; + private int age; + private String gender; + + Information() { + this.name = "Jimmeh"; + this.age = 21; + this.gender = "Male"; + } + + Information(String name, int age, String gender) { + this.name = name; + this.age = age; + this.gender = gender; + } + + + + // Public means that there is permission for other classes to use this + public String getName() { + return name; + } + public void setName(String newName) { + this.name = newName; + } + + public int getAge() { + return age; + } + public void setAge(int newAge) { + this.age = newAge; + } + + public String getGender() { + return gender; + } + public void setGender(String newGender) { + this.gender = newGender; + } + + public boolean getOlderThan21() { + if (this.age > 21) { + return true; + } else { + return false; + } + } + + public static void main(String[] args) { + Information justin = new Information("Justin", 17, "Male"); + Information weston = new Information("Weston", 22, "Mouse"); + + System.out.println(justin.getOlderThan21()); + System.out.println(weston.getOlderThan21()); + } +} + From 76a6bfa9f0d5ede7d1e37d9aa3bfcb474ef197fa Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Tue, 22 Oct 2024 17:32:05 -0700 Subject: [PATCH 32/36] removed white space --- Week3/Encapsulation/Information.java | 44 +++++++--------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/Week3/Encapsulation/Information.java b/Week3/Encapsulation/Information.java index 8ebeae1..98ad6e7 100644 --- a/Week3/Encapsulation/Information.java +++ b/Week3/Encapsulation/Information.java @@ -9,45 +9,24 @@ public class Information { this.age = 21; this.gender = "Male"; } - Information(String name, int age, String gender) { this.name = name; this.age = age; this.gender = gender; } - - - // Public means that there is permission for other classes to use this - public String getName() { - return name; - } - public void setName(String newName) { - this.name = newName; - } - - public int getAge() { - return age; - } - public void setAge(int newAge) { - this.age = newAge; - } - - public String getGender() { - return gender; - } - public void setGender(String newGender) { - this.gender = newGender; - } - + public String getName() {return name;} + public void setName(String newName) {this.name = newName;} + // Get Age + public int getAge() {return age;} + public void setAge(int newAge) {this.age = newAge;} + // Get gender + public String getGender() {return gender;} + public void setGender(String newGender) {this.gender = newGender;} + // Check older than 21 public boolean getOlderThan21() { - if (this.age > 21) { - return true; - } else { - return false; - } + if (this.age > 21) {return true;} else {return false;} } - public static void main(String[] args) { Information justin = new Information("Justin", 17, "Male"); Information weston = new Information("Weston", 22, "Mouse"); @@ -55,5 +34,4 @@ public static void main(String[] args) { System.out.println(justin.getOlderThan21()); System.out.println(weston.getOlderThan21()); } -} - +} \ No newline at end of file From ac776c4fbccaaf05c774ed545195217968617e15 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 24 Oct 2024 16:21:04 -0700 Subject: [PATCH 33/36] this breaks stuff --- Week3/Inheritance/Child.java | 16 ++++++++++++++++ Week3/Inheritance/Main.java | 22 +++++++++++----------- Week3/Inheritance/Parent.java | 12 ++++++++++++ Week3/Polymorphism/Calculator.java | 15 +-------------- Week3/Polymorphism/SlowCalculator.java | 18 ++++++++++++++++++ 5 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 Week3/Inheritance/Child.java create mode 100644 Week3/Inheritance/Parent.java create mode 100644 Week3/Polymorphism/SlowCalculator.java diff --git a/Week3/Inheritance/Child.java b/Week3/Inheritance/Child.java new file mode 100644 index 0000000..b4599bd --- /dev/null +++ b/Week3/Inheritance/Child.java @@ -0,0 +1,16 @@ +public class Child extends Parent { + String first_name; + + Child(String first_name, String lastName, String eyeColor) { + super(lastName, eyeColor); + this.first_name = first_name; + } + + void getFullName() { + System.out.println("This is" + first_name + " his last name is " + last_name + "."); + } + + void parentEyeColor() { + System.out.println("The parent has " + super.eye_color + " eyes."); + } +} diff --git a/Week3/Inheritance/Main.java b/Week3/Inheritance/Main.java index bb33acc..dc22c54 100644 --- a/Week3/Inheritance/Main.java +++ b/Week3/Inheritance/Main.java @@ -7,18 +7,18 @@ public static void main(String[] args) { } } -class Parent { - String last_name; - String eye_color; +// class Parent { +// String last_name; +// String eye_color; - Parent(String last_name, String eyeColor) { - this.last_name = last_name; - this.eye_color = eyeColor; - } - void getLastName() { - System.out.println("This person's last name is " + this.last_name); - } -} +// Parent(String last_name, String eyeColor) { +// this.last_name = last_name; +// this.eye_color = eyeColor; +// } +// void getLastName() { +// System.out.println("This person's last name is " + this.last_name); +// } +// } class Child extends Parent { String first_name; diff --git a/Week3/Inheritance/Parent.java b/Week3/Inheritance/Parent.java new file mode 100644 index 0000000..d668216 --- /dev/null +++ b/Week3/Inheritance/Parent.java @@ -0,0 +1,12 @@ +public class Parent { + String last_name; + String eye_color; + + Parent(String last_name, String eyeColor) { + this.last_name = last_name; + this.eye_color = eyeColor; + } + void getLastName() { + System.out.println("This person's last name is " + this.last_name); + } +} diff --git a/Week3/Polymorphism/Calculator.java b/Week3/Polymorphism/Calculator.java index 95bc1a5..615f68e 100644 --- a/Week3/Polymorphism/Calculator.java +++ b/Week3/Polymorphism/Calculator.java @@ -17,17 +17,4 @@ public static void main(String[] args) { jim.division(4.5, 1.5); jim.division(4, 2); } -} - -class SlowCalculator extends Calculator { - int num3; - - public Integer multiply(int num1, int num2) { - this.num3 = 0; - for (int i = 0; i < num2; i++) { - System.out.println(num3); - num3 = num1 + num3; - } - return this.num3; - } -} +} \ No newline at end of file diff --git a/Week3/Polymorphism/SlowCalculator.java b/Week3/Polymorphism/SlowCalculator.java new file mode 100644 index 0000000..85c7803 --- /dev/null +++ b/Week3/Polymorphism/SlowCalculator.java @@ -0,0 +1,18 @@ +import java.lang.Math; + +class SlowCalculator extends Calculator { + int num3; + + public Integer multiply(int num1, int num2) { + this.num3 = 0; + for (int i = 0; i < num2; i++) { + System.out.println(num3); + num3 = num1 + num3; + } + return this.num3; + } + + public void exponent(int x, int y) { + System.out.println("I don't work"); + } +} \ No newline at end of file From d1170f94260e16ac08d83fd11680cbe4833e8061 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 24 Oct 2024 16:21:19 -0700 Subject: [PATCH 34/36] fix later --- Week3/Polymorphism/SlowCalculator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Week3/Polymorphism/SlowCalculator.java b/Week3/Polymorphism/SlowCalculator.java index 85c7803..3eb4748 100644 --- a/Week3/Polymorphism/SlowCalculator.java +++ b/Week3/Polymorphism/SlowCalculator.java @@ -1,4 +1,4 @@ -import java.lang.Math; +// import java.lang.Math; class SlowCalculator extends Calculator { int num3; From 04d7e6eab1cc9ad22e8b66df4d1f00ea6b381056 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS Date: Thu, 24 Oct 2024 17:16:22 -0700 Subject: [PATCH 35/36] did pokemon work --- pokemon/Jigglypuff.java | 16 ++++++++++++++++ pokemon/Main.java | 18 ++++++++++++++++++ pokemon/Pikachu.java | 16 ++++++++++++++++ pokemon/Pokemon.java | 28 ++++++++++++++++++++++++++++ pokemon/README | 19 +++++++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 pokemon/Jigglypuff.java create mode 100644 pokemon/Main.java create mode 100644 pokemon/Pikachu.java create mode 100644 pokemon/Pokemon.java create mode 100644 pokemon/README diff --git a/pokemon/Jigglypuff.java b/pokemon/Jigglypuff.java new file mode 100644 index 0000000..2057c7e --- /dev/null +++ b/pokemon/Jigglypuff.java @@ -0,0 +1,16 @@ +package pokemon; + +public class Jigglypuff extends Pokemon { + public Jigglypuff(int health, String name, int attack) { + super(health, name, attack); + } + + private Jigglypuff() { + super(50, "Jigglypuff", 8); + } + + @Override + public void attack(Pokemon target) { + target.damageTaken(this.attack); + } +} diff --git a/pokemon/Main.java b/pokemon/Main.java new file mode 100644 index 0000000..8679311 --- /dev/null +++ b/pokemon/Main.java @@ -0,0 +1,18 @@ +package pokemon; + +public class Main { + public static void main(String[] args) { + Pokemon pikachu = new Pikachu(100, "Ash's Pikachu", 20); + Pokemon jigglypuff = new Jigglypuff(121, "Demon Slapping Singer", 6); + + while (pikachu.getIsFainted() || jigglypuff.getIsFainted()) { + pikachu.attack(jigglypuff); + jigglypuff.attack(pikachu); + } + if (pikachu.getIsFainted()) { + System.out.println(jigglypuff.getName() + " wins"); + } else { + System.out.println(pikachu.getName() + " Wins"); + } + } +} diff --git a/pokemon/Pikachu.java b/pokemon/Pikachu.java new file mode 100644 index 0000000..97b5cda --- /dev/null +++ b/pokemon/Pikachu.java @@ -0,0 +1,16 @@ +package pokemon; + +public class Pikachu extends Pokemon { + public Pikachu(int health, String name, int attack) { + super(health, name, attack); + }; + + private Pikachu() { + super(50, "Pikachu", 12); + }; + + @Override + public void attack(Pokemon target) { + target.damageTaken(this.attack); + }; +} diff --git a/pokemon/Pokemon.java b/pokemon/Pokemon.java new file mode 100644 index 0000000..3901190 --- /dev/null +++ b/pokemon/Pokemon.java @@ -0,0 +1,28 @@ +package pokemon; + +abstract public class Pokemon { + private int health; + private String name; + public int attack; + // Sets a default value for all Pokemon of 50 + public Pokemon(int health, String name, int attack) { + this.health = health; + this.name = name; + this.attack = attack; + } + // Abstract method to reprogram for attack + abstract void attack(Pokemon target); + // Takes a number it deals that much damage to the Pokemon + public void damageTaken(int dmg) { + this.health = this.health - dmg; + } + // Checks the status of isFainted to see if Pokemon is fainted + public boolean getIsFainted() { + boolean isFainted = health <= 0; + return isFainted; + } + // Returns the value of Pokemon's name + public String getName() { + return this.name; + } +} \ No newline at end of file diff --git a/pokemon/README b/pokemon/README new file mode 100644 index 0000000..b1654d7 --- /dev/null +++ b/pokemon/README @@ -0,0 +1,19 @@ +a. Explain why Pokemon should be an abstract class + Since it doesn't make sense for their to be a Pokemon since it is a concept + +b. Explain why inheriting from Pokemon is useful + Inheriting from Pokemon means you require much less work as it all already exists in Pokemon + +c. Explain an example of method polymorphism in your code + There is an example of method Polymorphism in my code when I override the the attack function + +d. Explain an example of subtype polymorphism in your code + When I create the default constructor, due to it having different parameters it does not throw an error + +e. Explain why you made one of your methods public + I made attack public so that the main file could reference it + +f. Explain why you made one of your instance variables private + I made health and name private because health and name do not need to be changed or referenced by other classes just set in the super. + + \ No newline at end of file From 9d83eb4edc469abd8e10091303e33d7bdfff1e52 Mon Sep 17 00:00:00 2001 From: JustinQ-DNHS <142454003+JustinQ-DNHS@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:06:09 -0700 Subject: [PATCH 36/36] Update README --- pokemon/README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pokemon/README b/pokemon/README index b1654d7..1886181 100644 --- a/pokemon/README +++ b/pokemon/README @@ -1,19 +1,19 @@ a. Explain why Pokemon should be an abstract class - Since it doesn't make sense for their to be a Pokemon since it is a concept + Since it doesn't make sense for there to be a Pokemon class since it is a concept b. Explain why inheriting from Pokemon is useful Inheriting from Pokemon means you require much less work as it all already exists in Pokemon c. Explain an example of method polymorphism in your code - There is an example of method Polymorphism in my code when I override the the attack function + There is an example of method Polymorphism in my code when I override the attack function d. Explain an example of subtype polymorphism in your code When I create the default constructor, due to it having different parameters it does not throw an error e. Explain why you made one of your methods public - I made attack public so that the main file could reference it + I made the attack method public so that the main file could reference it f. Explain why you made one of your instance variables private I made health and name private because health and name do not need to be changed or referenced by other classes just set in the super. - \ No newline at end of file +