Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I am working on the textbook problem found in chapter 8 question 16e The

ID: 3778800 • Letter: H

Question

Hello, I am working on the textbook problem found in chapter 8 question 16e The solution that has been provided by Chegg will not compile. The excercise in the text book is telling us to add an instructor class to the Lab-Class project that is provided on the CD and was discussed in chapter one. I used the solution provided by chegg for this excercise and i am getting the following errors when tyring to compile the code;.

constructor LabClass in class LabClass cannot be applied to given types:

required: int; found: int,java.lang.String; reason: actual and formal argument lists differ in length.

Here is what the solution in chegg says to enter, i have checked in a number of times.

instructor class:

public class Instructor extends LabClass
{
    // Full name
    private String name;
    // ID
    private String id;
    // Instuctors contact information
    private String address;
    private String phone;
    private String email;

    /**
     * Constructor for objects of class Instructor
     */
    public Instructor(int totalStudents, String fullName, String instructorID, String address, String phone, String email)
    {

        super(totalStudents, fullName);
        name = fullName;
        id = instructorID;
        address = address;
        phone = phone;
        email = email;
    }

    /**
     * Method to get instructor fullName
     */
    public String getName()
    {
        return Name;
    }

    /**
     * Method to get instructor ID
     */
    public String getinstructorID()
    {
        return id;
    }

    /**
     * Method to get instructor address.
     */
    public String getAddress()
    {
        return address;
    }

    /**
     * Method to get instructors phone.
     */
    public String getPhone()
    {
        return phone;
    }

    /**
     * Method to get instructors email.
     */
    public String getEmail()
    {
        return email;
    }

This is the code that has been provided by the textbook on the CD. that has been unaltered;

Class - LabClass

import java.util.*;

/**
* The LabClass class represents an enrolment list for one lab class. It stores
* the time, room and participants of the lab, as well as the instructor's name.
*
* */
public class LabClass
{
    private String instructor;
    private String room;
    private String timeAndDay;
    private ArrayList students;
    private int capacity;
   
    /**
     * Create a LabClass with a maximum number of enrolments. All other details
     * are set to default values.
     */
    public LabClass(int maxNumberOfStudents)
    {
        instructor = "unknown";
        room = "unknown";
        timeAndDay = "unknown";
        students = new ArrayList();
        capacity = maxNumberOfStudents;
    }

    /**
     * Add a student to this LabClass.
     */
    public void enrollStudent(Student newStudent)
    {
        if(students.size() == capacity) {
            System.out.println("The class is full, you cannot enrol.");
        }
        else {
            students.add(newStudent);
        }
    }
   
    /**
     * Return the number of students currently enrolled in this LabClass.
     */
    public int numberOfStudents()
    {
        return students.size();
    }
   
    /**
     * Set the room number for this LabClass.
     */
    public void setRoom(String roomNumber)
    {
        room = roomNumber;
    }
   
    /**
     * Set the time for this LabClass. The parameter should define the day
     * and the time of day, such as "Friday, 10am".
     */
    public void setTime(String timeAndDayString)
    {
        timeAndDay = timeAndDayString;
    }
   
    /**
     * Set the name of the instructor for this LabClass.
     */
    public void setInstructor(String instructorName)
    {
        instructor = instructorName;
    }
   
    /**
     * Print out a class list with other LabClass details to the standard
     * terminal.
     */
    public void printList()
    {
        System.out.println("Lab class " + timeAndDay);
        System.out.println("Instructor: " + instructor + "   Room: " + room);
        System.out.println("Class list:");
        for(Student student : students) {
            student.print();
        }
        System.out.println("Number of students: " + numberOfStudents());
    }
}

   

I am just tying to find out how to fix the problems with the solution that has been provided by Chegg for this excercise. I need to have this excercise completed by Thursday. and i can not figure out why it does not work.

Explanation / Answer

// i have highlighted the code that i have modified.

//you have not provided me the student class file so i have removed the error that you have specified in the question.

//below is the code for Instructor.java

public class Instructor extends LabClass
{
// Full name
private String name;
// ID
private String id;
// Instuctors contact information
private String address;
private String phone;
private String email;
/**
* Constructor for objects of class Instructor
*/
public Instructor(int totalStudents, String fullName, String instructorID, String address, String phone, String email)
{
super(totalStudents); //Lab constructor has only one parameter int we should remove the other.
name = fullName;
id = instructorID;
address = address;
phone = phone;
email = email;
}
/**
* Method to get instructor fullName
*/
public String getName()
{
return name;
}
/**
* Method to get instructor ID
*/
public String getinstructorID()
{
return id;
}
/**
* Method to get instructor address.
*/
public String getAddress()
{
return address;
}
/**
* Method to get instructors phone.
*/
public String getPhone()
{
return phone;
}
/**
* Method to get instructors email.
*/
public String getEmail()
{
return email;
}
}

//comment if you want further clarification.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote