Skip to content

Instantly share code, notes, and snippets.

@borncorp
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save borncorp/e1f8bab70c2ba9186476 to your computer and use it in GitHub Desktop.

Select an option

Save borncorp/e1f8bab70c2ba9186476 to your computer and use it in GitHub Desktop.
public class Bottle {
int capacity;
int used;
String contains;
String color;
public Bottle(int capacitycopy, int usedcopy, String containscopy, String colorcopy) {
this.capacity=capacitycopy;
this.used=usedcopy;
this.contains=containscopy;
this.color=colorcopy;
System.out.println("You have created a "
+ colorcopy
+ " bottle of "
+ containscopy
+ " .\nThe capacity is "
+ capacitycopy
+ ". Currently storing "
+ usedcopy
+ "ml");
}
public void drink(int howmuch) {
this.used=this.used-howmuch;
System.out.println("You have drink " + howmuch + "ml of " + this.color + " " + this.contains + "\n" + this.used + "ml left");
}
public void changeColor(String newcolor) {
this.color=newcolor;
System.out.println("The color of " + this.contains + " is now " + this.color);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment