KeezyEnraged
KeezyEnraged
CC#
Created by KeezyEnraged on 4/14/2023 in #help
❔ I couldn't figure out the solution. (Java)
Thanks for the link
11 replies
CC#
Created by KeezyEnraged on 4/14/2023 in #help
❔ I couldn't figure out the solution. (Java)
I don't support anything. it was a problem I had to solve.
11 replies
CC#
Created by KeezyEnraged on 4/14/2023 in #help
❔ I couldn't figure out the solution. (Java)
import java.util.*;


class Food {

private String name;


public String getFood(String name) {
this.name = name;

return name;
}

public Food() {

}

void serveFood() {
System.out.printf("I'm serving s%" , getFood(name));
}



}

class FoodFactory extends Food {


private String name;


public String getFood(String name) {


return name;
}

public void setFood(String name) {

this.name = name;
}

}

class Solution {
public static void main(String[] args) {
FoodFactory myFoods = new FoodFactory();
Food food1 = myFoods.getFood("FastFood");
Food food2 = myFoods.getFood("Fruit");
System.out.println("My name is: " + food1.getClass().getName());
System.out.println("My name is: " + food2.getClass().getName());
System.out.println("Our superclass is: "
+ food1.getClass().getSuperclass().getName());
food1.serveFood();
food2.serveFood();
}
}
import java.util.*;


class Food {

private String name;


public String getFood(String name) {
this.name = name;

return name;
}

public Food() {

}

void serveFood() {
System.out.printf("I'm serving s%" , getFood(name));
}



}

class FoodFactory extends Food {


private String name;


public String getFood(String name) {


return name;
}

public void setFood(String name) {

this.name = name;
}

}

class Solution {
public static void main(String[] args) {
FoodFactory myFoods = new FoodFactory();
Food food1 = myFoods.getFood("FastFood");
Food food2 = myFoods.getFood("Fruit");
System.out.println("My name is: " + food1.getClass().getName());
System.out.println("My name is: " + food2.getClass().getName());
System.out.println("Our superclass is: "
+ food1.getClass().getSuperclass().getName());
food1.serveFood();
food2.serveFood();
}
}
This was me trying to solve the problem
11 replies
CC#
Created by KeezyEnraged on 1/27/2023 in #help
❔ How is my counter not incrementing?
So it has to be globalized
7 replies
CC#
Created by KeezyEnraged on 1/27/2023 in #help
❔ How is my counter not incrementing?
Ahhhh
7 replies