Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. package muresan.daiana.lab4.ex4;
  2.  
  3. import muresan.daiana.lab4.ex2.Author;
  4.  
  5. public class TestBook {
  6. public static void main(String args[]) {
  7. Author a1 = new Author("DaianaMuresan", "muresandaiana@yahoo.com", 'f');
  8. Author a2 = new Author("CiceuTiberiu", "ciceutl@gmail.com", 'm');
  9. Author a3 = new Author("BodocanSebi", "bodos@hotmail.com", 'm');
  10. Author[] authors = new Author[3];
  11. authors[0] = a1;
  12. authors[1] = a2;
  13. authors[2] = a3;
  14. Book b1 = new Book("MyStory", authors, 50);
  15.  
  16. authors = new Author[2];
  17. authors[0] = a2;
  18. authors[1] = a3;
  19. Book b2 = new Book("AllAboutLove", authors, 100, 4);
  20.  
  21. authors = new Author[2];
  22. authors[0] = a1;
  23. authors[1] = a3;
  24. Book b3 = new Book("Attitude", authors, 120, 10);
  25.  
  26. System.out.println("Book Name : "+b1.getName());
  27. System.out.println("Authors: ");
  28. b1.printAuthors();
  29. System.out.println();
  30. System.out.println("Price : "+b1.getPrice());
  31. b1.setPrice(70);
  32. System.out.println("New Price : "+b1.getPrice());
  33. b1.setQtyInStock(80);
  34. System.out.println("New Quantity : "+b1.getQtyInStock());
  35. System.out.println(b1.toString());
  36.  
  37. System.out.println("\n");
  38.  
  39. System.out.println("Book Name : "+b2.getName());
  40. System.out.println("Authors: ");
  41. b2.printAuthors();
  42. System.out.println();
  43. System.out.println("Price : "+b2.getPrice());
  44. b2.setPrice(40);
  45. System.out.println("New Price : "+b2.getPrice());
  46. System.out.println("Quantity : "+b2.getQtyInStock());
  47. b2.setQtyInStock(8);
  48. System.out.println("New Quantity : "+b2.getQtyInStock());
  49. System.out.println(b2.toString());
  50.  
  51. System.out.println("\n");
  52.  
  53. System.out.println("Book Name : "+b3.getName());
  54. System.out.println("Authors: ");
  55. b3.printAuthors();
  56. System.out.println();
  57. System.out.println("Price : "+b3.getPrice());
  58. b3.setPrice(200);
  59. System.out.println("New Price : "+b3.getPrice());
  60. System.out.println("Quantity : "+b3.getQtyInStock());
  61. b3.setQtyInStock(60);
  62. System.out.println("New Quantity : "+b3.getQtyInStock());
  63. System.out.println(b3.toString());
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement