Skip to content

Commit e3ea3cd

Browse files
Updates
1 parent 70f82bb commit e3ea3cd

File tree

7 files changed

+79
-1
lines changed

7 files changed

+79
-1
lines changed

ArrayofObjects.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class ArrayofObjects{
2+
public static void main(String[] args){
3+
Food[] refrigerator = new Food[3];
4+
5+
Food food1 = new Food("pizza");
6+
Food food2 = new Food("hamburger");
7+
Food food3 = new Food("hotdog");
8+
9+
refrigerator[0] = food1;
10+
refrigerator[1] = food2;
11+
refrigerator[2] = food3;
12+
13+
System.out.println(refrigerator[0].name);
14+
System.out.println(refrigerator[1].name);
15+
System.out.println(refrigerator[2].name);
16+
17+
Food[] refrigerator2 = {food1, food2, food3};
18+
19+
}
20+
}

Car2.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Car2 {
2+
String make = "ford";
3+
String model = "Mustang";
4+
String color = "red";
5+
int year = 2021;
6+
7+
public String toString(){
8+
String myString = make + model + color + year;
9+
return myString;
10+
}
11+
}

Car3.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class Car3 {
2+
String name;
3+
Car3(String name){
4+
this.name = name;
5+
}
6+
}

Food.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class Food {
2+
String name;
3+
Food(String name){
4+
this.name = name;
5+
}
6+
}

Garage.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public class Garage {
2+
void park(Car3 car){
3+
return;
4+
}
5+
}

Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
public class Main{
22
public static void main(String[] args){
3-
DiceRoller dice = new DiceRoller();
3+
Garage garage = new Garage();
4+
Car3 car = new Car3("bmw");
5+
return;
46
}
57
}

Pizza.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
public class Pizza {
2+
String bread;
3+
String sauce;
4+
String cheese;
5+
String toppings;
6+
7+
Pizza(String bread, String sauce, String cheese, String toppings){
8+
this.bread = bread;
9+
this.sauce = sauce;
10+
this.cheese = cheese;
11+
this.toppings = toppings;
12+
}
13+
14+
Pizza(String bread, String sauce, String cheese){
15+
this.bread = bread;
16+
this.sauce = sauce;
17+
this.cheese = cheese;
18+
}
19+
20+
Pizza(String bread, String sauce){
21+
this.bread = bread;
22+
this.sauce = sauce;
23+
}
24+
25+
Pizza(String bread){
26+
this.bread = bread;
27+
}
28+
}

0 commit comments

Comments
 (0)