Hello in my online university center, they gave me this challenge in Java.
1. Declare an Employee class with String attributes for RFC, first name, last name, street address, postal code, and city. This class must include the object type job attribute of the JobPost class. Declare the JobPost class with String attributes for: code and description and a double attribute for the gross salary. Develop the constructor method in the declaration of both classes.
2. Develop a Java program that instantiates at least two objects of the Employee class declared in question 1.
3. Declare the Administrative and Consultant derived classes of the Employee class. The Administrative class has an attribute of type int for seniority. The Consultant class has a String attribute for the professional category. Develop the constructor method in the declaration of both classes. This method must call the constructor of the base class.
4. Develop a Java program that instantiates an object of the Administrative and Consultant classes declared in question 3.
5. Define the getAttributes() method of the Employee, Administrative and Consultant classes. The getAttributes() method of the Employee class must use the getDescription() method to display the job description. Methods
getAttributes() of the Administrative and Consultant subclasses must override the method of the Employee superclass.
So it leads me to think that Employee has a job position, and an employee, can be a consultant or an administrator, has seniority, in the end, the result will be displayed in the CMD, in this order, RFC, name, surname, address, Postal code, city, job position, Consultant or administrator, code, description, salary, category and seniority.
Therefore I have created the classes and objects without any attributes
They had been declared correctly, when I started giving attributes to objects with single quotes or without quotes. This was giving me errors. In the end this is JAVA source code. -
class Empleado {
-
public static void main(String[] arg){}
-
private String RFC;
-
private String nombre;
-
private String apellidos;
-
private String domicilio;
-
private String codigoPostal;
-
private String ciudad;
-
private PuestoTrabajo puestoTrabajo;
-
public Empleado(String RFC, String nombre, String apellidos, String domicilio, String codigoPostal, String ciudad, PuestoTrabajo puestoTrabajo)
-
{
-
this.RFC = RFC;
-
this.nombre = nombre;
-
this.apellidos = apellidos;
-
this.domicilio = domicilio;
-
this.codigoPostal = codigoPostal;
-
this.ciudad = ciudad;
-
this.PuestoTrabajo = puestoTrabajo;
-
Empleado empleado1 = new Empleado("qwerty1", "juan", "Garcia", "calle 3", "53700", "MEXICO", puesto1);
-
Empleado empleado1 = new Empleado("qwerty1", "maria", "barrera", "calle456", "53700", "Puebla", puesto2);
-
-
}
-
}
-
class PuestoTrabajo {
-
private String codigo;
-
private String descripcion;
-
private double sueldoBruto;
-
public PuestoTrabajo(String codigo, String descripcion, double sueldoBruto)
-
{
-
this.codigo = codigo;
-
this.descripcion = descripcion;
-
this.sueldoBruto = sueldoBruto;
-
PuestoTrabajo puesto1 = new PuestoTrabajo("P001", "Programador", 400);
-
}
-
public String getDescripcion(){
-
return descripcion;
-
}
-
}
-
-
class Consultor extends Empleado
-
{
-
public Consultor(String RFC, String nombre, String apellidos, String domicilio, String codigoPostal, String ciudad)
-
{
-
super(RFC, nombre, apellidos, domicilio, codigoPostal, ciudad, puestoTrabajo);
-
this.categoriaProfesional = categoriaProfesional;
-
Consultor consultor = new Consultor(empleado1, puesto1, "Senior", 5);
-
}
-
}
-
class Administrativo extends Empleado
-
{
-
private int Antiguedad;
-
public Administrativo(String RFC, String nombre, String apellidos, String domicilio, String codigoPostal, String ciudad, PuestoTrabajo puestoTrabajo, int Antiguedad)
-
{
-
super(RFC, nombre, apellidos, domicilio, codigoPostal, ciudad, puestoTrabajo);
-
this.Antiguedad = Antiguedad;
-
Administrativo admin = new Administrativo("qwerty1", "maria", "barrera", "calle456", "53700", "Puebla", puesto2, 5);
-
}
-
}
-
-
This is the error that given the CMD -
symbol: variable JobPosition
-
Employee.java:20: error: cannot find symbol
-
-
symbol: variable position1
-
location: class Employee
-
This error is repeated up to 10 times. The error is marked in the objects and the statement this and super
Could you please correct my code or tell me why it marks errors in objects and this and super instructions
1 13036
I have try your code in my ide, and found some errors.
you have define two symbol named [empleado1] . [puesto1] and [puesto2] are not defined yet.
Empleado empleado1 = new Empleado("qwerty1", "juan", "Garcia", "calle 3", "53700", "MEXICO", puesto1);
Empleado empleado1 = new Empleado("qwerty1", "maria", "barrera", "calle456", "53700", "Puebla", puesto2);
you can use an ide , for example Intelli IDEA , to make it easy to find errors.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ben |
last post by:
Hi all,
This may sound easy but I'm having trouble assigning values to array
element. My problem is as follows:
m =
for o in m:
# Here first o is 'Peter'.. I want to do something like this:...
|
by: ajit goel |
last post by:
Hi;
I have a question which respect to initialising and creating objects
in loops.Here are the 2 scenarios:
1.
###############################################################################...
|
by: Eric Bantock |
last post by:
Very basic question I'm afraid. Once an array has been declared, is there
a less tedious way of assigning values to its members than the following:
myarray=8;
myarray=3;
myarray=4;
myarray=0;...
|
by: Jim |
last post by:
I have some complex (fairly) user controls that I have created. Some of
those user controls host other user controls. When I host one of these on a
WinForm, I sometimes run into problems where...
|
by: chris |
last post by:
I know I've asked this before, but I didn't really get an answer and I
bet it's because I didn't explain myself very well. Here goes again.
I have this code:
Dim arrData(intNoOfRows,...
| |
by: Richard Thornley |
last post by:
Hello,
I need some clarification in creating objects. Consider the following
code... (note: The function InitializeListCombo initializes the combobox)
Private daLists As New...
|
by: JoeC |
last post by:
I have read books and have ideas on how to create objects. I often
create my own projects and programs. They end up getting pretty
complex and long. I often use objects in my programs they are...
|
by: Manuel Graune |
last post by:
Hello,
while trying to learn how to program using objects in python (up to now
simple scripts were sufficient for my needs) I stumbled over the
a problem while assigning values to an object.
...
|
by: Cliff |
last post by:
Hi,
I'm in the process of porting some code from a 3rd party and have hit
a problem with the following:
typedef struct {
unsigned char Red;
unsigned char Green;
unsigned char Blue;...
|
by: emyl |
last post by:
Hi all,
here's an elementary question. Assume I have declared two variables,
char *a, **b;
I can then give a value to a like
a="hello world";
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |