Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Snack {
- private String name;
- private double cost;
- Snack(String name, double cost) {
- this.name = name;
- this.cost = cost;
- }
- public String getSnack() {
- return name;
- }
- public void giveDiscount(double discount) {
- cost -= discount;
- }
- public void changeData(String name, double cost) {
- this.name = name;
- this.cost = cost;
- }
- public void changeSnack(String name) {
- this.name = name;
- }
- public void changePrice(double price) {
- cost = price;
- }
- public double getPrice() {
- return cost;
- }
- public String toString() {
- return name + ", " + cost;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement