954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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);
	}

}
rs_java
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 

It looks OK. What is your problem?

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 
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
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 

setVat(discount); setDiscount(vat);

rs_java
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 

I am sure that someone, someday will understand what you are trying to tell us

javaAddict
Nearly a Senior Poster
Team Colleague
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
 

so what a about the price

rs_java
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 

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
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 
rs_java
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 

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

rs_java
Newbie Poster
8 posts since Aug 2008
Reputation Points: 8
Solved Threads: 0
 
setVat(discount); setDiscount(vat);
so what a about the price

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.

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.

jasimp
Senior Poster
3,623 posts since Aug 2007
Reputation Points: 533
Solved Threads: 53
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You