Skip to content

Instantly share code, notes, and snippets.

@y0zg
Created March 13, 2016 15:19
Show Gist options
  • Save y0zg/9a5e4c36c70044cec591 to your computer and use it in GitHub Desktop.
Save y0zg/9a5e4c36c70044cec591 to your computer and use it in GitHub Desktop.
static factory methods
package com.db;
import java.time.LocalDate;
import java.util.Scanner;
public class meth {
public static void main(String arg[]) {
System.out.println("test");
Discount discount=Discount.MinDiscount();
System.out.println(discount.getValue());
}
}
package com.db;
import java.util.Dictionary;
/**
* Created by webstddesign on 13.03.2016.
*/
public class Discount {
private int value;
private Discount(int value) {
this.value=value;
}
public int getValue(){
return this.value;
}
public static Discount MinDiscount(){
return new Discount(10);
}
public static Discount MaxDiscount(){
return new Discount(30);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment