Question

You need to design and implement the following structure for your organization. You must follow the instructions given below

Need to write the program..
In java language.
And That the program should be according to given scenario..

0 0
Add a comment Improve this question Transcribed image text
Answer #1

There were a number of classes, interface, please go through them.

package qasim37189;

public interface Organization {
        void changeMoto(String moto);
        void changeName(String name);
        void foundOn(int year);
        void increasNetWorth(int worth);
        void increaseTurnOver(int amount);
}
package qasim37189;

import java.util.Date;

public interface Person{
        void setFirstName(String fname);
        void setSecondName(String sname);
        void setAge(int age);
        void setDOJ(Date doj);
        String getFirstName();
        String getSecondName();
        int getAge();
        Date getDOJ();
}
package qasim37189;

public abstract class Staff implements Person{

        float hoursWorkedThisWeek;
        float dailyWage;
        int numberOfleavesThisWeek;
        float rateOfIncome;
        float totalIncomeThisWeek;
        
        abstract void hoursWorkedThisWeek(float hours);
        abstract void dailyWage(float sum);
        abstract void numberOfleavesThisWeek(int leave);
        abstract void rateOfIncome(float rate);
        abstract void totalIncomeThisWeek(float income);
        
        Staff() {
                System.out.println("New Staff hired");
        }
}
package qasim37189;

import java.util.Date;

public abstract class Infrastructure {
        abstract void isWorking(boolean condition);
        abstract void lifeOfEquip(int life);
        abstract void price(float price);
        abstract void supplierName(String name);
        abstract void boughtOn(Date date);
        Infrastructure() {
                 System.out.println("Infrastructed set up done");
         }
}
package qasim37189;

import java.util.Date;

public class Laptop extends Infrastructure {
        
        boolean isWorking;
        int lifeOfEquip;
        float price;
        String supplierName;
        Date boughtOn;
        
        //override method implemented
        
        @Override
        void isWorking(boolean condition) {
                this.isWorking = condition;
        }

        @Override
        void lifeOfEquip(int life) {
                this.lifeOfEquip= life;
        }

        @Override
        void price(float price) {
                this.price = price;
        }

        @Override
        void supplierName(String name) {
                this.supplierName=name;
        }

        @Override
        void boughtOn(Date date) {
                this.boughtOn=date;
        }

        
        //setters
        
        public boolean isWorking() {
                return isWorking;
        }

        public int getLifeOfEquip() {
                return lifeOfEquip;
        }

        public float getPrice() {
                return price;
        }

        public String getSupplierName() {
                return supplierName;
        }

        public Date getBoughtOn() {
                return boughtOn;
        }
        
        

}
package qasim37189;

public class Ali implements Organization {

        int networth=0;
        int turnOver=0;
        Staff staff ;
        String moto="default moto";
        String name="default name";
        int foundOnYear=0;
        
        @Override
        public void increasNetWorth(int worth) {
                this.networth=this.networth+worth;
        }

        @Override
        public void increaseTurnOver(int amount) {
                this.turnOver=this.turnOver+amount;
        }

        public void setNetworth(int networth) {
                this.networth = networth;
        }

        public void setTurnOver(int turnOver) {
                this.turnOver = turnOver;
        }

        public void setStaff(Staff staff) {
                this.staff = staff;
        }

        public int getNetworth() {
                return networth;
        }

        public int getTurnOver() {
                return turnOver;
        }

        public Staff getStaff() {
                return staff;
        }

        @Override
        public void changeMoto(String moto) {
                this.moto= moto;
        }

        @Override
        public void changeName(String name) {
                this.name=name;
        }

        @Override
        public void foundOn(int year) {
                this.foundOnYear=year;
        }

}
package qasim37189;

import java.util.Date;

public class OperatorStaff extends Staff{

        //instance variable
        
        String firstName;
        String secondName;
        int age;
        String department;
        Date dateOfJoining;
        
        

        public OperatorStaff(String firstName, String secondName, int age, String department, Date dob) {
                super();
                this.firstName = firstName;
                this.secondName = secondName;
                this.age = age;
                this.department = department;
                this.dateOfJoining = dob;
        }

        @Override
        public void setFirstName(String fname) {
                this.firstName=fname;
        }

        @Override
        public void setSecondName(String sname) {
                this.secondName=sname;
        }

        @Override
        public void setAge(int age) {
                this.age=age;
        }

        @Override
        public void setDOJ(Date doj) {
                this.dateOfJoining=doj;
        }

        @Override
        void hoursWorkedThisWeek(float hours) {
                
        }

        @Override
        void dailyWage(float sum) {
                
        }

        @Override
        void numberOfleavesThisWeek(int leave) {
                        }

        @Override
        void rateOfIncome(float rate) {
                
        }

        @Override
        void totalIncomeThisWeek(float income) {
                
        }

        @Override
        public String getFirstName() {
                return this.firstName;
        }

        @Override
        public String getSecondName() {
                return this.secondName;
        }

        @Override
        public int getAge() {
                return this.age;
        }

        @Override
        public Date getDOJ() {
                return this.dateOfJoining;
        }

}
package qasim37189;

import java.util.Date;

public class MainClass {

        public static void main(String[] args) {
                Ali org = new Ali(); //organization created
                
                System.out.println("Initial Worth : "+org.networth);
                org.setStaff(new OperatorStaff("Tom", "Riddler", 30, "Operator", new Date()));
                org.increasNetWorth(500);
                org.increaseTurnOver(500);
                System.out.println("Name of the new operator added : "+org.getStaff().getFirstName());
                System.out.println("Networth now :"+ org.networth);
                
                //created 5 persons for example, you create as many as your ID
                Person[] persons = new Person[5];
                
                //Create as many staff as per your id , here for example 5 created
                //trying to find 6th person who doesn't exist , you try to find 1 more than your ID that will generate exception
                try {
                        System.out.println(persons[6].getFirstName());
                }
                //Exception handling
                catch (ArrayIndexOutOfBoundsException e) {
                        System.out.println("Trying to find Person who doesnt exists.");
                }
                
        }
                

}
Add a comment
Know the answer?
Add Answer to:
Need to write the program.. In java language. And That the program should be according to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is...

    [Continued] Your Course class should have: 1)a getter for the course 'code', so that it is read-only; 2)a getter and setter for the lecturer attribute, so that it is readable and writable; 3)a constructor that creates the associations shown in the UML diagram; 4)an enrolStudent method that adds a given Student object into the 'enrolled' set; 5)a withdrawStudent method that removes a given Student object from the 'enrolled' set and returns true if the student was successfully found and removed,...

  • Write java program The purpose of this assignment is to practice OOP with Array and Arraylist,...

    Write java program The purpose of this assignment is to practice OOP with Array and Arraylist, Class design, Interfaces and Polymorphism. Create a NetBeans project named HW3_Yourld. Develop classes for the required solutions. Important: Apply good programming practices Use meaningful variable and constant names. Provide comment describing your program purpose and major steps of your solution. Show your name, university id and section number as a comment at the start of each class. Submit to Moodle a compressed folder of...

  • Intel 80x86 microprocessors 1. (%25) Write an assembly language program which asks the user to enter...

    Intel 80x86 microprocessors 1. (%25) Write an assembly language program which asks the user to enter his/her name and surname through the keyboard. After the entry: The program clears the left top quarter of the screen and displays the name at the center of that quarter. Similarly the program clears the right bottom quarter of the screen and displays the surname at the center of that quarter. For example: If your name and surname are "Al and "Velir, the following...

  • program Java oop The project description As a programmer; you have been asked to write a...

    program Java oop The project description As a programmer; you have been asked to write a program for a Hospital with the following The Hospital has several employees and each one of them has an ID, name, address, mobile number, email and salary. . The employees are divided into Administration staff: who have in addition to the previous information their position. Nurse: who have their rank and specialty stored in addition to the previous o o Doctor: who have the...

  • Hi I need help doing this problem *The program must re-prompt as long as invalid input...

    Hi I need help doing this problem *The program must re-prompt as long as invalid input is inserted Implement a program that manages shapes. Implement a class named Shape with a virtual function area()which returns the double value. Implement three derived classes named Diamond, Oval, and Pentagon. Declare necessary properties in each including getter and setter function and a constructor that sets the values of these properties. Override the area() function in each by calculating the area using the defined...

  • I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You...

    I need help with this program using c++ language! CS 317 Program Assignment Name Arrange You are to write a program that will read in each person’s name and print out the results. The list has been collected form different places and the names are not in some standard format. A person’s last name may appear last or it may appear first. A label has been associated with each name to identify where the last name appears. Either “surname” or...

  • In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a...

    In this lab you will work with abstract classes/interfaces. (Java Program) You will be implementing a basic employee schema within a company. The Employee class will be an abstract class that will contain methods applicable to all employees. You will then create 2 classes called SoftwareEngineer and ProductManager. Both are different employee types based on occupation. You will create an interface called Developer which will consist of specific methods that apply to only Developers (e.g. SoftwareEngineer class will implement this,...

  • Write a program in Java, Python and Lisp When the program first launches, there is a...

    Write a program in Java, Python and Lisp When the program first launches, there is a menu which allows the user to select one of the following five options: 1.) Add a guest 2.) Add a room 3.) Add a booking 4.) View bookings 5.) Quit The functionality of these options is as follows: 1.) When users add a guest they provide a name which is stored in some manner of array or list. Guests are assigned a unique ID...

  • You have to write a java solution for a store. Part 1 The solution needs to...

    You have to write a java solution for a store. Part 1 The solution needs to have at least following features: ◦ Item: Name, ID (incremental ID by 1 for each product), Price. ◦ Store Basket: ID (incremental ID by 1 for each basket), Net Amount, Total Amount, VAT, List of items, Date and Time of purchase, Address of the store, name of cashier. ◦ Cashier: Name, Surname, Username and Password (insert from code five fixed cashiers). ◦ Manager: Name,...

  • The project description As a programmer; you have been asked to write a program for a Hospital wi...

    program Java oop The project description As a programmer; you have been asked to write a program for a Hospital with the following The Hospital has several employees and each one of them has an ID, name, address, mobile number, email and salary. . The employees are divided into Administration staff: who have in addition to the previous information their position. Nurse: who have their rank and specialty stored in addition to the previous o o Doctor: who have the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT