Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Week3/Abstraction/README.md
Original file line number Diff line number Diff line change
@@ -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
```
24 changes: 24 additions & 0 deletions Week3/Arrays/Arrays.java
Original file line number Diff line number Diff line change
@@ -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]);
}
}
}
16 changes: 16 additions & 0 deletions Week3/Arrays/README.txt
Original file line number Diff line number Diff line change
@@ -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
```
21 changes: 21 additions & 0 deletions Week3/Classes & Objects/Me.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
23 changes: 23 additions & 0 deletions Week3/Classes & Objects/Pokemon.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
13 changes: 13 additions & 0 deletions Week3/Classes & Objects/README.md
Original file line number Diff line number Diff line change
@@ -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
```
14 changes: 14 additions & 0 deletions Week3/Encapsulation/README.md
Original file line number Diff line number Diff line change
@@ -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
```
43 changes: 43 additions & 0 deletions Week3/Inheritance/Child.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
31 changes: 31 additions & 0 deletions Week3/Inheritance/Main.java
Original file line number Diff line number Diff line change
@@ -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());
}
}
37 changes: 37 additions & 0 deletions Week3/Inheritance/Parent.java
Original file line number Diff line number Diff line change
@@ -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;
}
}

21 changes: 21 additions & 0 deletions Week3/Inheritance/README.md
Original file line number Diff line number Diff line change
@@ -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
```
17 changes: 17 additions & 0 deletions Week3/Polymorphism/README.md
Original file line number Diff line number Diff line change
@@ -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
```
24 changes: 24 additions & 0 deletions Week3/Project/Charizard.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
19 changes: 19 additions & 0 deletions Week3/Project/Main.java
Original file line number Diff line number Diff line change
@@ -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 :(");
}
}
}
24 changes: 24 additions & 0 deletions Week3/Project/Pikachu.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Loading