-2

This Is my Assignment, I am having Troubles Getting my Class To Work With main for, Can Someone please Help Me, This is due on Tuesday and I have been hitting a brick wall in every approach I have tried. all my class and my forms are posted. Please Help me I am totally lost and frustrated 1.Employee and ProductionWorker Classes

Create an Employee class that has properties for the following data: •Employee name •Employee number

Next, create a class named ProductionWorker that is derived from the Employee class.

The ProductionWorker class should have properties to hold the following data: •Shift number ( an integer, such as 1, 2, or 3) •Hourly pay rate The workday is divided into two shifts: day and night.

The Shift property will hold an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2.

Create an application that creates an object of the ProductionWorker class and lets the user enter data for each of the object’s properties. Retrieve the object’s properties and display their values.

This Is My Employee Reference Chart. To Store Their Names And I.D Numbers I am getting no compiling errors on this class, however I am not sure if I am doing this correctly because in my main I get a compiling error.

I assume I need an array to store all the data that will be inputted into my TextBox in visual

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Employee_References
{
  class Roster
{
 // Field for name, ID, dept, and position  
 private const int NAMES = 100;
 private static string [] employee = new string [NAMES];
 private const int NUMBER = 100;
 private static int [] id = new int [NUMBER];
 private int total = 0;



 public void Employee()
 {
     total = 0;
 }

  // This will recieve input from my main 
  public static void employeeName (string [] xArray)   

{
        for (int index = 0; index < xArray.Length; index++)
        {
            xArray[index] = employee[NAMES];
        }
}


   // This will recieve input from my main 
   public static void idNumber ( int [] zArray)
{
   for (int index = 0; index < zArray.Length; index++)
    {
        zArray[index] = id[NUMBER];
    }
}


 }

}

This will be my next class that is derived from my first class as my assignment requested. This class is suppose to store the shift numbers 1 through for 4, and an hourly wage setter for a Day and Night Shift. I am getting one compiling error in this class that says " The left-hand side of an assignment must be a variable, property or indexer" I am not sure What it is telling me, can someone please explain what it is trying to tell me. Am I doing this correctly?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

   namespace Employee_References
   {
      class References : Roster
   {   

    // Field for name, ID, dept, and position  

    private int shift;
    private static const double PAYRATEDAY = 12.75;
    private static const double PAYRATENIGHT = 15.75;



 public void Employee()
 {

 }

  // This will recieve input from my main 
  public int shifts   

{  
    set {shift = value;}  // this set the recieve value of name one and set it to name1
    get {return shift; }  //this will get name1 and send it to my main.

}


   // This will recieve input from my main 
   public double payrate1 
   {
    set { PAYRATEDAY = value; } // ERROR!!The left-hand side of an assignment must be a variable, property or indexer
    get { return PAYRATEDAY; }  

   }


  // This will recieve input from my main 
  public double payrate2 
   {
       get { return PAYRATENIGHT; } // ERROR!!The left-hand side of an assignment must be a   variable, property or indexer
       set { PAYRATENIGHT = value; }          
   }
}

This is my Form, I am trying to send my input values into my class my "Roster" class That has an array of 100. How ever I keep getting a compiling error that says " Cannot assign to 'employeeName' because it is a 'method group". I am not sure What It is telling me can some one explain this to me, and give me some pointer on how to do this

using System;
using System.Windows.Forms;

namespace Employee_References
{
public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Roster Chart = new Roster();
        Chart.employeeName = name.Text; // Error **Cannot assign to 'employeeName' because it is a 'method group**".  
    }
}

}

Yosi Dahari
  • 6,794
  • 5
  • 24
  • 44
ErickBRCC
  • 1
  • 5
  • http://meta.stackexchange.com/questions/10647/how-do-i-write-a-good-title – Soner Gönül Nov 17 '13 at 20:00
  • 1
    I can understand that you feel panic, we all do (sometimes), but there is no way to help you unless you show a clear & concrete problem. – Yosi Dahari Nov 17 '13 at 20:02
  • What I don't Understand is How to Receive The input from the user, then store it, Finally retrieve it. I Have started With this code but it seem like I am hitting a brick wall. should I use another approach to this porblem – ErickBRCC Nov 17 '13 at 20:05
  • I am not even sure If I need An array to do this assignment. Should I use An array for this Assignment or Not? – ErickBRCC Nov 17 '13 at 20:05
  • How will I be able to retrieve my input from my classes, should I have another Form? – ErickBRCC Nov 17 '13 at 20:06
  • I am also very confused on how to send user input into my classes? I tried doing this but I am getting compiling errors – ErickBRCC Nov 17 '13 at 20:07
  • 2
    relax, stop commenting for a while, focus your energy in "cleaning" the post, you won't get much help with how it looks right now. – Yosi Dahari Nov 17 '13 at 20:09
  • Please, **at least** format the question so that the code is properly **indented and readable**. – Ondrej Tucny Nov 17 '13 at 20:21

2 Answers2

0

employeeName() is a method and you are trying to assign it a value.

Looks like you want to try and pass an array of names to it as a parameter

//first define and populate myArray
Chart.employeeName(myArray)
jazza1000
  • 4,099
  • 3
  • 44
  • 65
0

You say

private static const double PAYRATEDAY = 12.75;

Then

public double payrate1 
   {
    set { PAYRATEDAY = value; } // ERROR!!The left-hand side of an assignment must be a variable, property or indexer
    get { return PAYRATEDAY; }  

   }

Why do you declare the field constant if you are changing it?

Also, I think you'd be better off using lists instead of arrays, so that it can grow dynamically as much as it needs instead of being limited by a fix number.

CloneXpert
  • 246
  • 2
  • 9