Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3d00c40

Browse files
authored
Child Classes in Arrays and ArrayLists add folder
1 parentff1e71a commit3d00c40

File tree

1 file changed

+42
-0
lines changed
  • Inheritance and Polymorphism/Child Classes in Arrays and ArrayLists

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
classNoodle {
2+
3+
protecteddoublelengthInCentimeters;
4+
protecteddoublewidthInCentimeters;
5+
protectedStringshape;
6+
protectedStringingredients;
7+
protectedStringtexture ="brittle";
8+
9+
Noodle(doublelenInCent,doublewthInCent,Stringshp,Stringingr) {
10+
11+
this.lengthInCentimeters =lenInCent;
12+
this.widthInCentimeters =wthInCent;
13+
this.shape =shp;
14+
this.ingredients =ingr;
15+
16+
}
17+
18+
publicStringgetCookPrep() {
19+
20+
return"Boil noodle for 7 minutes and add sauce.";
21+
22+
}
23+
24+
25+
publicstaticvoidmain(String[]args) {
26+
27+
Noodlespaghetti,ramen,pho;
28+
29+
spaghetti =newSpaghetti();
30+
ramen =newRamen();
31+
pho =newPho();
32+
Noodle[]allTheNoodles = {spaghetti,ramen,pho};
33+
// Add your code below:
34+
for (Noodlenoodle :allTheNoodles){
35+
System.out.println(noodle.getCookPrep());
36+
37+
38+
}
39+
40+
}
41+
42+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp