Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oop_final;
- public class Inventory {
- int FZS;
- int R15_V3;
- int Fazer;
- int R15_V2;
- public Inventory() {
- this.FZS = 100;
- this.R15_V3 = 100;
- this.Fazer = 100;
- this.R15_V2 = 100;
- }
- void sellFZS()throws MyException{
- if(FZS < 30)
- {
- this.FZS=100;
- throw new MyException();
- }
- else{
- FZS--;
- System.out.println("FZS= "+FZS);
- }
- }
- void sellR15_V3()throws MyException{
- if(R15_V3 < 40)
- {
- this.R15_V3=100;
- throw new MyException();
- }
- else{
- R15_V3--;
- System.out.println("R15_V3 = "+R15_V3);
- }
- }
- void sellFazer()throws MyException{
- if(Fazer < 34)
- {
- this.Fazer=100;
- throw new MyException();
- }
- else{
- Fazer--;
- System.out.println("Fazer = "+Fazer);
- }
- }
- void sellR15_V2()throws MyException{
- if(R15_V2 < 50)
- {
- this.R15_V2=100;
- throw new MyException();
- }
- else{
- R15_V2--;
- System.out.println("R15_V2 = "+R15_V2);
- }
- }
- }
- *********************************************************
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package oop_final;
- /**
- *
- * @author Naimul
- */
- public class Showroom extends Inventory {
- void sellFZS()throws MyException{
- if(FZS < 30)
- {
- this.FZS=100;
- throw new MyException();
- }
- else{
- FZS--;
- System.out.println("FZS= "+FZS);
- }
- }
- void sellR15_V3()throws MyException{
- if(R15_V3 < 40)
- {
- this.R15_V3=100;
- throw new MyException();
- }
- else{
- R15_V3--;
- System.out.println("R15_V3 = "+R15_V3);
- }
- }
- void sellFazer()throws MyException{
- if(Fazer < 34)
- {
- this.Fazer=100;
- throw new MyException();
- }
- else{
- Fazer--;
- System.out.println("Fazer = "+Fazer);
- }
- }
- void sellR15_V2()throws MyException{
- if(R15_V2 < 50)
- {
- this.R15_V2=100;
- throw new MyException();
- }
- else{
- R15_V2--;
- System.out.println("R15_V2 = "+R15_V2);
- }
- }
- }
- ************************************************
- package oop_final;
- public class Test {
- public static void main(String[] args) throws MyException {
- Inventory ob = new Inventory();
- Showroom ob1=new Showroom();
- try{
- for(int i=0;i<75;i++)
- {
- ob.sellFZS();
- }
- }
- catch(Exception e)
- {
- System.out.println("Inventory running dry");
- }
- ob.sellFZS();
- ob1.sellFazer();
- ob1.sellFazer();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement