Advertisement
Naimul_X

Untitled

Jan 4th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1.  
  2. package oop_final;
  3.  
  4. public class Inventory {
  5. int FZS;
  6. int R15_V3;
  7. int Fazer;
  8. int R15_V2;
  9.  
  10. public Inventory() {
  11. this.FZS = 100;
  12. this.R15_V3 = 100;
  13. this.Fazer = 100;
  14. this.R15_V2 = 100;
  15. }
  16. void sellFZS()throws MyException{
  17.  
  18. if(FZS < 30)
  19. {
  20. this.FZS=100;
  21. throw new MyException();
  22.  
  23. }
  24. else{
  25. FZS--;
  26. System.out.println("FZS= "+FZS);
  27. }
  28. }
  29. void sellR15_V3()throws MyException{
  30.  
  31. if(R15_V3 < 40)
  32. {
  33. this.R15_V3=100;
  34. throw new MyException();
  35.  
  36. }
  37. else{
  38. R15_V3--;
  39. System.out.println("R15_V3 = "+R15_V3);
  40.  
  41. }
  42.  
  43. }
  44. void sellFazer()throws MyException{
  45.  
  46. if(Fazer < 34)
  47. {
  48. this.Fazer=100;
  49. throw new MyException();
  50.  
  51. }
  52. else{
  53. Fazer--;
  54. System.out.println("Fazer = "+Fazer);
  55. }
  56.  
  57. }
  58. void sellR15_V2()throws MyException{
  59.  
  60. if(R15_V2 < 50)
  61. {
  62. this.R15_V2=100;
  63. throw new MyException();
  64.  
  65. }
  66. else{
  67. R15_V2--;
  68. System.out.println("R15_V2 = "+R15_V2);
  69. }
  70.  
  71. }
  72. }
  73.  
  74. *********************************************************
  75.  
  76. /*
  77. * To change this license header, choose License Headers in Project Properties.
  78. * To change this template file, choose Tools | Templates
  79. * and open the template in the editor.
  80. */
  81. package oop_final;
  82.  
  83. /**
  84. *
  85. * @author Naimul
  86. */
  87. public class Showroom extends Inventory {
  88.  
  89. void sellFZS()throws MyException{
  90.  
  91. if(FZS < 30)
  92. {
  93. this.FZS=100;
  94. throw new MyException();
  95.  
  96. }
  97. else{
  98. FZS--;
  99. System.out.println("FZS= "+FZS);
  100. }
  101. }
  102. void sellR15_V3()throws MyException{
  103.  
  104. if(R15_V3 < 40)
  105. {
  106. this.R15_V3=100;
  107. throw new MyException();
  108.  
  109. }
  110. else{
  111. R15_V3--;
  112. System.out.println("R15_V3 = "+R15_V3);
  113.  
  114. }
  115.  
  116. }
  117. void sellFazer()throws MyException{
  118.  
  119. if(Fazer < 34)
  120. {
  121. this.Fazer=100;
  122. throw new MyException();
  123.  
  124. }
  125. else{
  126. Fazer--;
  127. System.out.println("Fazer = "+Fazer);
  128. }
  129.  
  130. }
  131. void sellR15_V2()throws MyException{
  132.  
  133. if(R15_V2 < 50)
  134. {
  135. this.R15_V2=100;
  136. throw new MyException();
  137.  
  138. }
  139. else{
  140. R15_V2--;
  141. System.out.println("R15_V2 = "+R15_V2);
  142. }
  143.  
  144.  
  145. }
  146. }
  147.  
  148. ************************************************
  149.  
  150.  
  151. package oop_final;
  152.  
  153.  
  154. public class Test {
  155. public static void main(String[] args) throws MyException {
  156. Inventory ob = new Inventory();
  157. Showroom ob1=new Showroom();
  158. try{
  159. for(int i=0;i<75;i++)
  160. {
  161. ob.sellFZS();
  162. }
  163.  
  164. }
  165. catch(Exception e)
  166. {
  167. System.out.println("Inventory running dry");
  168. }
  169. ob.sellFZS();
  170. ob1.sellFazer();
  171. ob1.sellFazer();
  172. }
  173. }
  174.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement