- Joined
- Jul 12, 2017
- Posts
- 202
- Reaction
- 34
- Points
- 119
- Age
- 28
Mga boss dko po alam pano mag store ng objects sa array bale subclasses po tos ioutput using loop.
Ganto po dapat output. Salamat in advance mga boss.
Ask lng po. Kelangan ba dito ng if-else para no Gore-Tex at Gore-Tex ung output??
Heto po ung mga codes:
//Main.java
package SubnSupr;
public class Main {
public static void main(String args[]) {
Running r = new Running(250, "Nike", 43);
Walking w1 = new Walking(true, "Hanwag", 43.5);
Walking w2 = new Walking(false, "Merrell", 42);
Shoe[] arr = {r, w1, w2};
}
}
// Superclass: Shoe.java
package SubnSupr;
public class Shoe {
public final String brand;
public final double size;
Shoe(String brand, double size) {
this.brand = brand;
this.size = size;
}
}
//Subclass: Walking.java
package SubnSupr;
public class Walking extends Shoe {
public final boolean goreTex;
Walking(boolean goreTex, String brand, double size) {
super(brand, size);
this.goreTex = goreTex;
}
}
//Sublcass Running.java
package SubnSupr;
public class Running extends Shoe{
public final double weight;
Running(double weight, String brand, double size) {
super(brand, size);
this.weight = weight;
}
}
Ganto po dapat output. Salamat in advance mga boss.
Ask lng po. Kelangan ba dito ng if-else para no Gore-Tex at Gore-Tex ung output??
Heto po ung mga codes:
//Main.java
package SubnSupr;
public class Main {
public static void main(String args[]) {
Running r = new Running(250, "Nike", 43);
Walking w1 = new Walking(true, "Hanwag", 43.5);
Walking w2 = new Walking(false, "Merrell", 42);
Shoe[] arr = {r, w1, w2};
}
}
// Superclass: Shoe.java
package SubnSupr;
public class Shoe {
public final String brand;
public final double size;
Shoe(String brand, double size) {
this.brand = brand;
this.size = size;
}
}
//Subclass: Walking.java
package SubnSupr;
public class Walking extends Shoe {
public final boolean goreTex;
Walking(boolean goreTex, String brand, double size) {
super(brand, size);
this.goreTex = goreTex;
}
}
//Sublcass Running.java
package SubnSupr;
public class Running extends Shoe{
public final double weight;
Running(double weight, String brand, double size) {
super(brand, size);
this.weight = weight;
}
}
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.