Question

In: Computer Science

Create Course object class (Course.java) Course object should be the following attributes: Course id:12345 Instructor id:...

  • Create Course object class (Course.java)
    • Course object should be the following attributes:
      • Course id:12345
      • Instructor id: 9876
      • Room id: 101

I have everything written out but it won't compile, any help?

public class Course
{
   private int course id;
   private int instructor id;
   private int room id;

   Course()
   {
       setCourseID (13233);
       setInsID    (001);
       setRoomID    (101);
   }

   Course(int courseID, int instructorID, int roomID)
   {
       setCourseID    (courseID);
       setInsID        (instructorID);
       setRoomID        (roomID);
   }

   public int getCourseID()
   {
       return courseID;
}

public int getInsID()
   {
       return instructorID;
}

public int getRoomID()
   {
       return roomID;
}

{
       System.out.println("Course ID : " + getCourseID());
       System.out.println("Instructor ID : " + getInsID());
       System.out.println("Room ID : " + getRoomID());
   }
}


Solutions

Expert Solution

public class Course {
    private int courseID;
    private int instructorID;
    private int roomID;

    public Course() {
        setCourseID(13233);
        setInsID(001);
        setRoomID(101);
    }

    public Course(int courseID, int instructorID, int roomID) {
        setCourseID(courseID);
        setInsID(instructorID);
        setRoomID(roomID);
    }

    public int getCourseID() {
        return courseID;
    }

    public int getInsID() {
        return instructorID;
    }

    public int getRoomID() {
        return roomID;
    }

    public void setCourseID(int courseID) {
        this.courseID = courseID;
    }

    public void setInsID(int instructorID) {
        this.instructorID = instructorID;
    }

    public void setRoomID(int roomID) {
        this.roomID = roomID;
    }

    public void print() {
        System.out.println("Course ID : " + getCourseID());
        System.out.println("Instructor ID : " + getInsID());
        System.out.println("Room ID : " + getRoomID());
    }

    public static void main(String[] args) {
        Course course = new Course();
        course.setCourseID(7);
        course.setInsID(77);
        course.setRoomID(17);

        course.print();
    }
}


Related Solutions

Give an example of a class containing attributes and operations. Instantiate (create) an object of your...
Give an example of a class containing attributes and operations. Instantiate (create) an object of your class
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name...
Using JAVA Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last...
Create a class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyEmployee that inherits from the Employee class.   HourEmployee must use the inherited parent class variables and add in HourlyRate and HoursWorked. Your HourEmployee class should contain a constructor that calls the constructor from the...
Create a class Client. Your Client class should include the following attributes: Company Name (string) Company...
Create a class Client. Your Client class should include the following attributes: Company Name (string) Company id (string) Billing address (string) Billing city (string) Billing state (string) Write a constructor to initialize the above Employee attributes. Create another class HourlyClient that inherits from the Client class.   HourClient must use the inherited parent class variables and add in hourlyRate and hoursBilled. Your Hourly Client class should contain a constructor that calls the constructor from the Client class to initialize the common...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string)...
Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings. Create another class HourlyEmployee that inherits from the abstract Employee class. HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...
Create a class named GameCharacter to define an object as follows: The class should contain class...
Create a class named GameCharacter to define an object as follows: The class should contain class variables for charName (a string to store the character's name), charType (a string to store the character's type), charHealth (an int to store the character's health rating), and charScore (an int to store the character's current score). Provide a constructor with parameters for the name, type, health and score and include code to assign the received values to the four class variables. Provide a...
Consider the following schema: Student(id, name) Registration(id, code) Course(code, instructor) A) Explain how we can violate...
Consider the following schema: Student(id, name) Registration(id, code) Course(code, instructor) A) Explain how we can violate the foreign key constraint from the id attribute of Registration to the Student relation.   Ans. B)Give the following queries in the relational algebra. 1)What are the names of students registered in IT244?    Ans. 2 )What are the names of students registered in both IT244 and CS141? Ans.                                 3)What are the names of students who are...
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All...
JAVA PROGRAMMING Part 1 Create a class Student, with attributes id, first name, last name. (All the attributes must be String) Create a constructor that accepts first name and last name to create a student object. Create appropriate getters and setters Create another class StudentOperationClient, that contains a main program. This is the place where the student objects are created and other activities are performed. In the main program, create student objects, with the following first and last names. Chris...
object oriented programming java Create a Student class that have two data members id (assign to...
object oriented programming java Create a Student class that have two data members id (assign to your ID) and name (assign to your name). Create the object of the Student class by new keyword and printing the objects value. You may name your object as Student1. The output should be like this: 20170500 Asma Zubaida
Define and implement class Course. This class should contain the following fields: course name, course description,...
Define and implement class Course. This class should contain the following fields: course name, course description, department, time the course starts, weekday the course is held on (for simplicity, let us assume the course only meets once a week). This class should contain getters and setters for all its attributes. This class also needs at least one constructor. Save this class and its definition into a file named Course.java. Define and implement class Student. This class should contain the following...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT