Drenriza
September 15th, 2014, 01:59 PM
Hi guys and gails.
At the moment im looking into Java, and are in that regard looking for a good active Java forum. If anyone have some good experiences with specific forums please let me know about them.
Other than that i have a open programming question someone might be able to help me with here, since their is many talented people in all areas.
I'am currently making a softdrink "machine", where i have two classes to make these. One with all the variables that different softdrink shares and one with specific variables. One for Coca Cola, Pepsi, Sprite and so on.
But when i make my softdrink object, how do i merge it with the CocaCola object. So the variables from the two different classes are combined.
The current code i work with to make the first object is as follows
//main class
ArrayList<Softdrink> softDrinkArray = new ArrayList<Softdrink>();
for(byte count = 0; count < 20; count++) {
softDrinkArray.add(new Softdrink(5, 20, "x", "x"));
}
//softdrink class
public class Softdrink {
private int size;
private int price;
private String expirationDate;
private String manufactureDate;
public Softdrink() {
//Empty constructor
}
public Softdrink(int size, int price, String expirationDate, String manufactureDate) {
this.size = size;
this.price = price;
this.expirationDate = expirationDate; //going to make this a real datetime objects at some point
this.manufactureDate = manufactureDate; //going to make this a real datetime objects at some point
}
public int getSize() {
return size;
}
public int getPrice() {
return price;
}
public String getExpirationDate() {
return expirationDate;
}
public String getManufactureDate() {
return manufactureDate;
}
}
//CocaCola class
public class CocaCola {
private String name;
//nutritional content
private String PER;
private String energy;
private String carbohydrate;
private String sugar;
public CocaCola() {
name = "Coca Cola";
PER = "100ml";
energy = "180KJ / 42kcal";
carbohydrate = "10.6g";
sugar = "10.6g";
}
}
Thanks on advance :KS
Kind regards.
At the moment im looking into Java, and are in that regard looking for a good active Java forum. If anyone have some good experiences with specific forums please let me know about them.
Other than that i have a open programming question someone might be able to help me with here, since their is many talented people in all areas.
I'am currently making a softdrink "machine", where i have two classes to make these. One with all the variables that different softdrink shares and one with specific variables. One for Coca Cola, Pepsi, Sprite and so on.
But when i make my softdrink object, how do i merge it with the CocaCola object. So the variables from the two different classes are combined.
The current code i work with to make the first object is as follows
//main class
ArrayList<Softdrink> softDrinkArray = new ArrayList<Softdrink>();
for(byte count = 0; count < 20; count++) {
softDrinkArray.add(new Softdrink(5, 20, "x", "x"));
}
//softdrink class
public class Softdrink {
private int size;
private int price;
private String expirationDate;
private String manufactureDate;
public Softdrink() {
//Empty constructor
}
public Softdrink(int size, int price, String expirationDate, String manufactureDate) {
this.size = size;
this.price = price;
this.expirationDate = expirationDate; //going to make this a real datetime objects at some point
this.manufactureDate = manufactureDate; //going to make this a real datetime objects at some point
}
public int getSize() {
return size;
}
public int getPrice() {
return price;
}
public String getExpirationDate() {
return expirationDate;
}
public String getManufactureDate() {
return manufactureDate;
}
}
//CocaCola class
public class CocaCola {
private String name;
//nutritional content
private String PER;
private String energy;
private String carbohydrate;
private String sugar;
public CocaCola() {
name = "Coca Cola";
PER = "100ml";
energy = "180KJ / 42kcal";
carbohydrate = "10.6g";
sugar = "10.6g";
}
}
Thanks on advance :KS
Kind regards.