book class

Thread Solved

Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

book class

 
0
  #1
Aug 26th, 2008
  1. public class book {
  2. private double basePrice = 0;
  3. private double vat = 0;
  4. private double discount = 0;
  5. private double sellPrice;
  6.  
  7. public book() {
  8. setBasePrice(0);
  9. setVat(0);
  10. setDiscount(0);
  11. }
  12.  
  13. public book(double basePrice, double discount, double vat) {
  14. setBasePrice(basePrice);
  15. setVat(discount);
  16. setDiscount(vat);
  17. }
  18.  
  19. public double getBasePrice() {
  20. return basePrice;
  21. }
  22.  
  23. public void setBasePrice(double basePrice) {
  24. if (basePrice >= 0)
  25. this.basePrice = basePrice;
  26. setSellPrice();
  27. }
  28.  
  29. public double getVat() {
  30. return vat;
  31. }
  32.  
  33. public void setVat(double vat) {
  34. if (vat >= 0)
  35. this.vat = vat;
  36. setSellPrice();
  37. }
  38.  
  39. public double getDiscount() {
  40. return discount;
  41. }
  42.  
  43. public void setDiscount(double discount) {
  44. if (discount >= 0)
  45. this.discount = discount;
  46. setSellPrice();
  47. }
  48.  
  49. public double getSellPrice() {
  50. return sellPrice;
  51. }
  52.  
  53. private void setSellPrice() {
  54. sellPrice = basePrice * ((100 + (vat - discount)) / 100);
  55. }
  56.  
  57. }
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,633
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 222
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: book class

 
0
  #2
Aug 26th, 2008
It looks OK. What is your problem?
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
0
  #3
Aug 26th, 2008
  1. package com.bookPortal.model;
  2.  
  3. public class Book {
  4. private double basePrice = 0;
  5. private int vat = 0;
  6. private int discount = 0;
  7. private double sellPrice;
  8.  
  9. public Book() {
  10. setBasePrice(0);
  11. setVat(0);
  12. setDiscount(0);
  13. }
  14.  
  15. public Book(double basePrice, int discount, int vat) {
  16. setBasePrice(basePrice);
  17. setVat(discount);
  18. setDiscount(vat);
  19. }
  20.  
  21. public double getBasePrice() {
  22. return basePrice;
  23. }
  24.  
  25. public void setBasePrice(double basePrice) {
  26. if (basePrice >= 0)
  27. this.basePrice = basePrice;
  28. setSellPrice();
  29. }
  30.  
  31. public int getVat() {
  32. return vat;
  33. }
  34.  
  35. public void setVat(int vat) {
  36. if (vat >= 0)
  37. this.vat = vat;
  38. setSellPrice();
  39. }
  40.  
  41. public int getDiscount() {
  42. return discount;
  43. }
  44.  
  45. public void setDiscount(int discount) {
  46. if (discount >= 0)
  47. this.discount = discount;
  48. setSellPrice();
  49. }
  50.  
  51. public double getSellPrice() {
  52. return sellPrice;
  53. }
  54.  
  55. private void setSellPrice() {
  56. sellPrice = basePrice * (100 + vat - discount) / 100;
  57. if (sellPrice < 0)
  58. sellPrice = 0;
  59. }
  60.  
  61. }



  1. package com.bookPortal.modelTest;
  2.  
  3. import com.bookPortal.model.Book;
  4.  
  5. import junit.framework.TestCase;
  6.  
  7. public class BookTest extends TestCase{
  8. Book b = new Book();
  9.  
  10. public void testSetBasePrice(){
  11. b.setBasePrice(10);
  12. assertEquals(10.0, b.getBasePrice());
  13. }
  14. public void testWrongSetBasePrice(){
  15. b.setBasePrice(-10);
  16. assertEquals(0.0, b.getBasePrice());
  17. }
  18.  
  19. public void testSetVat(){
  20. b.setVat(10);
  21. assertEquals(10, b.getVat());
  22. }
  23. public void testWrongSetVat(){
  24. b.setVat(-10);
  25. assertEquals(0, b.getVat());
  26. }
  27.  
  28. public void testSetDiscount(){
  29. b.setDiscount(10);
  30. assertEquals(10, b.getDiscount());
  31. }
  32. public void testWrongSetDiscount(){
  33. b.setDiscount(-10);
  34. assertEquals(0, b.getDiscount());
  35. }
  36.  
  37. public void testSetSellPrice(){
  38. b.setBasePrice(10);
  39. b.setDiscount(0);
  40. b.setVat(18);
  41. assertEquals(11.80, b.getSellPrice());
  42. }
  43. public void testWrongSetSellPrice(){
  44. b.setBasePrice(0);
  45. b.setDiscount(50);
  46. b.setVat(18);
  47. assertEquals(0.0, b.getSellPrice());
  48. }
  49.  
  50. }

Tests successfull
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
0
  #4
Aug 26th, 2008
setVat(discount); setDiscount(vat);
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,633
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 222
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: book class

 
0
  #5
Aug 26th, 2008
I am sure that someone, someday will understand what you are trying to tell us
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
0
  #6
Aug 26th, 2008
so what a about the price
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
0
  #7
Aug 26th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
0
  #8
Aug 26th, 2008
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 8
Reputation: rs_java is an unknown quantity at this point 
Solved Threads: 0
rs_java rs_java is offline Offline
Newbie Poster

Re: book class

 
-1
  #9
Aug 26th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 3,584
Reputation: jasimp has a spectacular aura about jasimp has a spectacular aura about jasimp has a spectacular aura about 
Solved Threads: 51
Featured Poster
jasimp's Avatar
jasimp jasimp is offline Offline
Senior Poster

Re: book class

 
0
  #10
Aug 26th, 2008
Originally Posted by rs_java View Post
setVat(discount); setDiscount(vat);
Originally Posted by rs_java View Post
so what a about the price
Originally Posted by rs_java View Post
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.
Originally Posted by rs_java View Post
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.
"Argyou not with the hand you are dealt in cards or life." ---- Wizard and Glass
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC