DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   book class (http://www.daniweb.com/forums/thread142366.html)

rs_java Aug 26th, 2008 9:29 am
book class
 
public class book {
        private double basePrice = 0;
        private double vat = 0;
        private double discount = 0;
        private double sellPrice;

        public book() {
                setBasePrice(0);
                setVat(0);
                setDiscount(0);
        }

        public book(double basePrice, double discount, double vat) {
                setBasePrice(basePrice);
                setVat(discount);
                setDiscount(vat);
        }

        public double getBasePrice() {
                return basePrice;
        }

        public void setBasePrice(double basePrice) {
                if (basePrice >= 0)
                        this.basePrice = basePrice;
                setSellPrice();
        }

        public double getVat() {
                return vat;
        }

        public void setVat(double vat) {
                if (vat >= 0)
                        this.vat = vat;
                setSellPrice();
        }

        public double getDiscount() {
                return discount;
        }

        public void setDiscount(double discount) {
                if (discount >= 0)
                        this.discount = discount;
                setSellPrice();
        }

        public double getSellPrice() {
                return sellPrice;
        }

        private void setSellPrice() {
                sellPrice = basePrice * ((100 + (vat - discount)) / 100);
        }

}

javaAddict Aug 26th, 2008 9:49 am
Re: book class
 
It looks OK. What is your problem?

rs_java Aug 26th, 2008 10:28 am
Re: book class
 
package com.bookPortal.model;

public class Book {
        private double basePrice = 0;
        private int vat = 0;
        private int discount = 0;
        private double sellPrice;

        public Book() {
                setBasePrice(0);
                setVat(0);
                setDiscount(0);
        }

        public Book(double basePrice, int discount, int vat) {
                setBasePrice(basePrice);
                setVat(discount);
                setDiscount(vat);
        }

        public double getBasePrice() {
                return basePrice;
        }

        public void setBasePrice(double basePrice) {
                if (basePrice >= 0)
                        this.basePrice = basePrice;
                setSellPrice();
        }

        public int getVat() {
                return vat;
        }

        public void setVat(int vat) {
                if (vat >= 0)
                        this.vat = vat;
                setSellPrice();
        }

        public int getDiscount() {
                return discount;
        }

        public void setDiscount(int discount) {
                if (discount >= 0)
                        this.discount = discount;
                setSellPrice();
        }

        public double getSellPrice() {
                return sellPrice;
        }

        private void setSellPrice() {
                sellPrice = basePrice * (100 + vat - discount) / 100;
                if (sellPrice < 0)
                        sellPrice = 0;
        }

}



package com.bookPortal.modelTest;

import com.bookPortal.model.Book;

import junit.framework.TestCase;

public class BookTest extends TestCase{
        Book b = new Book();
       
        public void testSetBasePrice(){
                b.setBasePrice(10);
                assertEquals(10.0, b.getBasePrice());
        }
        public void testWrongSetBasePrice(){
                b.setBasePrice(-10);
                assertEquals(0.0, b.getBasePrice());
        }
       
        public void testSetVat(){
                b.setVat(10);
                assertEquals(10, b.getVat());
        }
        public void testWrongSetVat(){
                b.setVat(-10);
                assertEquals(0, b.getVat());
        }
       
        public void testSetDiscount(){
                b.setDiscount(10);
                assertEquals(10, b.getDiscount());
        }
        public void testWrongSetDiscount(){
                b.setDiscount(-10);
                assertEquals(0, b.getDiscount());
        }
       
        public void testSetSellPrice(){
                b.setBasePrice(10);
                b.setDiscount(0);
                b.setVat(18);
                assertEquals(11.80, b.getSellPrice());
        }
        public void testWrongSetSellPrice(){
                b.setBasePrice(0);
                b.setDiscount(50);
                b.setVat(18);
                assertEquals(0.0, b.getSellPrice());
        }

}

Tests successfull

rs_java Aug 26th, 2008 10:47 am
Re: book class
 
setVat(discount); setDiscount(vat);

javaAddict Aug 26th, 2008 10:57 am
Re: book class
 
I am sure that someone, someday will understand what you are trying to tell us

rs_java Aug 26th, 2008 1:11 pm
Re: book class
 
so what a about the price

rs_java Aug 26th, 2008 1:17 pm
Re: book class
 
product owner responsibility: Put into a simple list, typical product owner responsibilities are:

decide on the project vision - who is going to benefit from the project and how;
secure funding;
continuously make decisions on the product priorities - what is more important with the latest information in mind;
continuously make decisions on maximizing the product ROI - make sure the features with the biggest benefit/cost ratio are developed first.

rs_java Aug 26th, 2008 1:59 pm
Re: book class
 
http://www.cyberarmy.net/library/article/202

rs_java Aug 26th, 2008 3:24 pm
Re: book class
 
XP Practices:
-Collective ownership
-coding standards
-sustainable pace
-test first
-acceptance tests
-automation
-onsite customer
-continuous integration
-pair programming
-metaphor
-refactoring
-incremental design
-stories
-small releases
-planning game
-informatie workspace

jasimp Aug 26th, 2008 4:18 pm
Re: book class
 
Quote:

Originally Posted by rs_java (Post 678360)
setVat(discount); setDiscount(vat);

Quote:

Originally Posted by rs_java (Post 678482)
so what a about the price

Quote:

Originally Posted by rs_java (Post 678488)
product owner responsibility: Put into a simple list, typical product owner responsibilities are:

decide on the project vision - who is going to benefit from the project and how;
secure funding;
continuously make decisions on the product priorities - what is more important with the latest information in mind;
continuously make decisions on maximizing the product ROI - make sure the features with the biggest benefit/cost ratio are developed first.

Quote:

Originally Posted by rs_java (Post 678595)
XP Practices:
-Collective ownership
-coding standards
-sustainable pace
-test first
-acceptance tests
-automation
-onsite customer
-continuous integration
-pair programming
-metaphor
-refactoring
-incremental design
-stories
-small releases
-planning game
-informatie workspace

What am I thinking right now? You should be able to guess correctly because I have seen the proof of how advanced your website to user mind reading capabilities are.


All times are GMT -4. The time now is 9:50 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC