-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1ca8fcb
Showing
9 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>Miam</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import my.stomach.Stomach; | ||
|
||
/** | ||
* @author pteyssier | ||
* | ||
*/ | ||
public class Main { | ||
|
||
/** | ||
* @param args | ||
*/ | ||
public static void main(String[] args) { | ||
Stomach stomach = new Stomach(); | ||
System.out.println(stomach); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package my.food; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
|
||
public class ChaShaoBao implements Food { | ||
|
||
List<String> ingredients = new ArrayList<String>(); | ||
|
||
/* Exercise 1: implement Constructor */ | ||
|
||
@Override | ||
public List<String> getIngredients() { | ||
return ingredients; | ||
} | ||
|
||
@Override | ||
public String getCountryOrigin() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public Integer getCalory() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package my.food; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class DanDanMian implements Food { | ||
List<String> ingredients = new ArrayList<String>(); | ||
|
||
/* Exercise 1: implement Constructor */ | ||
|
||
@Override | ||
public List<String> getIngredients() { | ||
return ingredients; | ||
} | ||
|
||
@Override | ||
public String getCountryOrigin() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public Integer getCalory() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package my.food; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author pteyssier | ||
* | ||
*/ | ||
public interface Food { | ||
|
||
public List<String> getIngredients(); | ||
|
||
public String getCountryOrigin(); | ||
|
||
/* Exercise 4 */ | ||
public Integer getCalory(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package my.food; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/* | ||
* Class Food sample Pizza : | ||
* do not modify! | ||
* do not feed after midnight! | ||
* */ | ||
public class Pizza implements Food { | ||
|
||
List<String> ingredients = new ArrayList<String>(); | ||
|
||
public Pizza() { | ||
ingredients.add("ham"); | ||
ingredients.add("mozzarella"); | ||
ingredients.add("tomato"); | ||
} | ||
|
||
@Override | ||
public List<String> getIngredients() { | ||
return ingredients; | ||
} | ||
|
||
@Override | ||
public String getCountryOrigin() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
@Override | ||
public Integer getCalory() { | ||
// TODO Auto-generated method stub | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package my.stomach; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.sun.xml.internal.ws.util.StringUtils; | ||
|
||
import my.food.ChaShaoBao; | ||
import my.food.DanDanMian; | ||
import my.food.Food; | ||
import my.food.Pizza; | ||
|
||
public class Stomach { | ||
|
||
List<Food> foodsInside = new ArrayList<Food>(); | ||
|
||
public Stomach() { | ||
foodsInside.add(new Pizza()); | ||
/* Exercise 2 : add your food */ | ||
} | ||
@Override | ||
public String toString() { | ||
StringBuilder sb = new StringBuilder("My stomach contains " + foodsInside.size() + " food(s):\n\n"); | ||
for (Food food : foodsInside) { | ||
sb.append(foodsInside.indexOf(food) + 1 + ")"); | ||
|
||
/* Display the name of the food object */ | ||
sb.append(food.getClass().getSimpleName() + ":"); | ||
sb.append("\n"); | ||
|
||
/* Display the list of ingredients */ | ||
sb.append(food.getIngredients()); | ||
sb.append("\n\n"); | ||
|
||
/* Exercise 3: Display the country of origin see class Country */ | ||
|
||
} | ||
return sb.toString(); | ||
} | ||
} |