diff options
Diffstat (limited to 'Week16 Webshop/src')
8 files changed, 209 insertions, 24 deletions
diff --git a/Week16 Webshop/src/com/camilstaps/webshop/article/Article.java b/Week16 Webshop/src/com/camilstaps/webshop/article/Article.java index c0e53e5..911adcf 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/article/Article.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/article/Article.java @@ -1,11 +1,32 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.article; /** - * - * @author camilstaps + * An article has a description and a price. Subclasses should implement { @link + * #getShippingCosts() }. + * @author Camil Staps */ public abstract class Article { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/article/WashingMachine.java b/Week16 Webshop/src/com/camilstaps/webshop/article/WashingMachine.java index 37325f5..6325c29 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/article/WashingMachine.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/article/WashingMachine.java @@ -1,11 +1,31 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.article; /** - * - * @author camilstaps + * Washing machine: €499,- and €30,- shipping + * @author Camil Staps */ public class WashingMachine extends Article { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/article/WaterMelon.java b/Week16 Webshop/src/com/camilstaps/webshop/article/WaterMelon.java index 0cdf1d4..2c0f77e 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/article/WaterMelon.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/article/WaterMelon.java @@ -1,11 +1,31 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.article; /** - * - * @author camilstaps + * Water melon: €4,50 and €6,75 shipping + * @author Camil Staps */ public class WaterMelon extends Article { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/article/WineGlass.java b/Week16 Webshop/src/com/camilstaps/webshop/article/WineGlass.java index 81e38e5..5bbf2fe 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/article/WineGlass.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/article/WineGlass.java @@ -1,11 +1,31 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.article; /** - * - * @author camilstaps + * Wine glass: €8,50 and €6,75 shipping + * @author Camil Staps */ public class WineGlass extends Article { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/payment/CreditCard.java b/Week16 Webshop/src/com/camilstaps/webshop/payment/CreditCard.java index 4ce6b31..f2d0b31 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/payment/CreditCard.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/payment/CreditCard.java @@ -1,13 +1,33 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.payment; import java.util.Date; /** - * - * @author camilstaps + * PaymentMethod with Credit Card + * @author Camil Staps */ public class CreditCard implements PaymentMethod { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/payment/IDeal.java b/Week16 Webshop/src/com/camilstaps/webshop/payment/IDeal.java index 43c95bf..05247f1 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/payment/IDeal.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/payment/IDeal.java @@ -1,40 +1,79 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.payment; import java.util.Scanner; /** - * + * PaymentMethod using iDeal * @author camilstaps */ public class IDeal implements PaymentMethod { private String bank, accountNr, pincode; - private Scanner sc = new Scanner(System.in); + private final Scanner sc = new Scanner(System.in); + /** + * Create object without specifying data (user will be asked for needed data + * on {@link self#pay }). + */ public IDeal() { } + /** + * Create object with specified data + * @param bank + * @param accountNr + * @param pincode + */ public IDeal(String bank, String accountNr, String pincode) { this.bank = bank; this.accountNr = accountNr; this.pincode = pincode; } + /** + * Make sure bank != null + */ private void ensureBank() { if (bank != null) return; System.out.print("Bank: "); bank = sc.nextLine(); } + /** + * Make sure accountNr != null + */ private void ensureAccountNr() { if (accountNr != null) return; System.out.print("Account nr: "); accountNr = sc.nextLine(); } + /** + * Make sure pincode != null + */ private void ensurePincode() { if (pincode != null) return; System.out.print("Pincode: "); diff --git a/Week16 Webshop/src/com/camilstaps/webshop/payment/PayPal.java b/Week16 Webshop/src/com/camilstaps/webshop/payment/PayPal.java index c893da1..a752453 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/payment/PayPal.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/payment/PayPal.java @@ -1,11 +1,31 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.payment; /** - * - * @author camilstaps + * PaymentMethod using PayPal + * @author Camil Staps */ public class PayPal implements PaymentMethod { diff --git a/Week16 Webshop/src/com/camilstaps/webshop/payment/PaymentMethod.java b/Week16 Webshop/src/com/camilstaps/webshop/payment/PaymentMethod.java index 966fcf2..e1aeccf 100644 --- a/Week16 Webshop/src/com/camilstaps/webshop/payment/PaymentMethod.java +++ b/Week16 Webshop/src/com/camilstaps/webshop/payment/PaymentMethod.java @@ -1,14 +1,39 @@ /* - * Copyright (c) 2015 Camil Staps + * The MIT License (MIT) + * + * Copyright (c) 2015 Camil Staps <info@camilstaps.nl> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ package com.camilstaps.webshop.payment; /** - * - * @author camilstaps + * A PaymentMethod can be used to pay some amount + * @author Camil Staps */ public interface PaymentMethod { + /** + * Pay + * @param amount the amount to pay + * @return true iff the payment succeeded + */ boolean pay(double amount); } |