Hi
I have the following class to write, with respective methods and such(see below).
The script I have written so far is also attached. I am battling with two parts of this question. I'd like to include a test class to see whether this works but don't know how to override the protected fields so that I can pass properties to my analyst or programmer class.
Lastly, I have no idea how the ToString() method works to apply it to the script as the question asks : "Now override the ToString method to display the employee's information, e.g.: Programmer (Senior): John Doe (7402293945084)".
I have tried all sorts of different ways of doing this but it's kinda like trying to find a needle in a haystack. Any help would be appreciated. 2 1230
A further attempt whic I think is a bit neater but still no joy :( - using System;
-
-
abstract public class Employee
-
{
-
protected string name;
-
protected string idNumber;
-
protected int experience;
-
-
public Employee()
-
{
-
}
-
-
public Employee(string strName, string strIDNumber)
-
{
-
this.name = strName;
-
this.idNumber = strIDNumber;
-
}
-
-
public abstract string Evaluate();
-
-
abstract public int Experience
-
{
-
get;
-
set;
-
}
-
-
}
-
-
public class Programmer : Employee
-
{
-
int count ;
-
string PSenior ;
-
string PJunior ;
-
-
-
public Programmer()
-
{
-
count = 0;
-
PSenior = "Senior";
-
PJunior = "Junior";
-
}
-
-
-
public Programmer(string strName, string strIDNumber, int IntExperience) : base(strName, strIDNumber)
-
{
-
this.experience = IntExperience;
-
}
-
-
public override int Experience
-
{
-
get
-
{
-
for (count = 0; count <= 10; count++);
-
return experience;
-
}
-
set
-
{
-
experience = value;
-
count = count + 1;
-
}
-
}
-
-
public override string Evaluate()
-
{
-
if (experience > 5) {
-
return PSenior;
-
}
-
else {
-
return PJunior;
-
}
-
}
-
-
public override string ToString()
-
{
-
return "[" +
-
name +
-
", " +
-
idNumber +
-
", " +
-
experience;
-
}
-
-
}
-
-
public class Analyst : Employee
-
{
-
int count = 0;
-
string ASenior ;
-
string AJunior ;
-
-
public Analyst()
-
{
-
count = 0;
-
ASenior = "Senior";
-
AJunior = "Junior";
-
}
-
-
public Analyst(string strName, string strIDNumber, int IntExperience) : base(strName, strIDNumber)
-
{
-
this.experience = IntExperience;
-
}
-
-
-
public override int Experience
-
{
-
get
-
{
-
for (count = 0; count <= 20; count++);
-
return experience;
-
}
-
set
-
{
-
experience = value;
-
count = count + 1;
-
}
-
}
-
-
public override string Evaluate()
-
{
-
if (experience > 12) {
-
return ASenior;
-
}
-
else {
-
return AJunior;
-
}
-
}
-
-
public override string ToString()
-
{
-
return "[" +
-
name + // is this how I write ToString method to display information
-
", " +
-
idNumber +
-
", " +
-
experience;
-
}
-
-
-
}
-
-
-
public class Test
-
{
-
public static void Main()
-
{
-
Programmer mp = new Programmer("John Doe",
-
"7402293945084",
-
5
-
); // I'd like to test these properties
-
-
Console.WriteLine("Phew:",
-
mp.ToString()); // or
-
Console.WriteLine("Still not",
-
mp.Evaluate());
-
}
-
}
Regarding your ToString() overriding question, try this: - Console.WriteLine("Phew:{0}",
-
mp.ToString());
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michelle Keys |
last post by:
I am trying to call a print function to print a string from a database
using javascript.
Which is RC_DATA of Varchar2(2500).
This is a javascript is not being used. I have a thing that needs to...
|
by: ratnakarp |
last post by:
Hi,
I have a search text box. The user enters the value in the text box and
click on enter button. In code behind on button click i'm writing the
code to get the values from the database and...
|
by: Mikey |
last post by:
Sample VB .NET source code to create mailing labels or customized letters
using MS Word MailMerge
This VB .NET source code will start MS Word and call methods and set
properties in MS Word to...
|
by: ransoma22 |
last post by:
I developing an application that receive SMS from a connected GSM
handphone, e.g Siemens M55, Nokia 6230,etc through the data cable.
The application(VB.NET) will receive the SMS automatically,...
|
by: Babillon |
last post by:
Hello all. I'm writting a little application to help me expand my knowledge
in a few different areas. The app is, as you might of guessed from the
subject, a system metrics display using WMI. For...
| |
by: mahajanvit |
last post by:
Hi one and all
I got this problem during my project. So in order to solve this I made
a very small application. I am trying to insert using SP and
sqldatasource control. I know that while using...
|
by: Kevin Blount |
last post by:
Here's the code I tried, and found it failed...
<form runat="server" method="post" name="CreditCardForm"
id="CreditCardForm">
<%
foreach (object item in Request.Form)
{
if...
|
by: PaullyB |
last post by:
Hi There
I'm trying to insert a CSV file into SQL Database using C#. I can read the csv file and insert it into the table, however any fields with an embebbed comma are not being read correctly. How...
|
by: satyabhaskar |
last post by:
hi all,
In my web page i have created radio buttons dynamically on to the page .....following is my code
string Course, Semester, Section;
int rowsCount;
string con =...
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |