Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3443638
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:48:57+00:00 2026-05-18T08:48:57+00:00

I have an abstract class Employee , and based on that, I created the

  • 0

I have an abstract class Employee, and based on that, I created the following subclasses:

FulltimeEmployee
PartTimeEmployee
Salesman

as well as one standalone class, Orders.

I use the Orders class to "describe the salesman" by sending an array of orders in the Salesman constructor:

public Salesman(String firstname, String lastname,int code, String address,
                String city,int tk,int phone,String email,int deptcode,int card,
                double hours,String cat,int orderno,double salary,
                Orders[] order){
 super(  firstname, lastname, code,  address, city, tk, phone, email, deptcode,
         card, hours, cat );
 this.orderno=orderno;
 
 setBaseSalary( salary );
 getSalary(orders);
 /////////////////

 }

Later, I use that array to calculate the bonus a salesman gets, depending on the amount of sales he makes.

In main, I created an array of type Employee:

Employee employees[] = new Employee[ 7 ];
   employees[ 0 ] = salary1;
   employees[ 1 ] = salary2;
   employees[ 2 ] = salary3;
   employees[ 3 ] = partt1;
   employees[ 4 ] = partt2;
   employees[ 5 ] = sales1;
   employees[ 6 ] = sales;

where each row is a different type of employee (salary = full-time, partt = part-time, and sales = salesman).

My problem is that I want to print the orders of each salesman using the employees array.
What I’ve done so far is

for (int i=5;i<employees.length;i++){
              System.out.printf("Orders of Salesman: %S %S",
                  employees[i].getName(),employees[i].getSurname());
              System.out.printf(" Total amount(money) from orders: %,.0f ",
                  employees[i].earnings());
              int j=0;
              ((Salesman)employees[i]).getOrderNo(arr) ;
              //((Orders)employees[i]).getOrderNo();
              System.out.printf("ordernumber: %d  orderdate:%s  description: %s
                  order amount(money): %,.0f\n ");
                 
           }

The problem comes here:

System.out.printf("ordernumber: %d orderdate:%s description: %s order amount(money): %,.0f\n ");

How do I access the orders array inside of the Salesman object on employees array?
I have tried casting, but it won’t work because Orders is not a subclass of Employee.

I need it to print, for example,

Orders of Salesman: john koun

Total amount of orders: 13000
Orders per Salesman

Order number: 1 order date: 10/2/2010 description: machinery sale order amount: 12000

Order number: 2 order date: 20/2/2010 description: sales of parts order amount: 1000

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:48:57+00:00Added an answer on May 18, 2026 at 8:48 am

    your Salesman constructor accepts an Order[] orders but it doesn’t look like you keep a reference to it anywhere (unless you do that in getSalary or in the commented out portion).

    You will need to add something like

    this.orders = orders;

    in your Salesman constructor so you can refer to the array as a field/property of the Salesman object.

    Typically you should use the Bean pattern whereby each field has a getter/setter method:

    public Order[] getOrders(){
        return orders;
    }
    
    public void setOrders(Order[] orders){
        this.orders=orders;
    }
    

    then in your constructor add setOrders(orders);

    and then in your debug/output code add:

    Salesman salesman = (Salesman) employees[i];
    for (Order order : salesman.getOrders())
        System.out.println(order); // i don't know what fields order has!
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an abstract base class called Person with subclasses Employee and Customer. How
I have an abstract class Employee and 2 other classes that extend it (Developer
hi I have a parent class that is Abstract Employee and I have childrens
I want to have an abstract class Employee, and 2 derived classes; Staff and
Let's say I have an abstract base class that looks like this: class StellarObject(BaseModel):
I have an abstract class MotherClass and two abstract classes ChildClass1 and ChildClass2 that
I have an abstract class in C++ with several subclasses. Is it somehow by
I have an abstract class that has a shared method which creates a new
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have an abstract class and I would like to use it quickly by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.