//Student.java
public class Student {
// fields
private int idStudent;
private String name;
private String major;
private String classification;
// defaulr constructor
public Student()
{
idStudent = 0;
name="";
major = "";
classification = "";
}
// parameterized constructor 1
public Student(int idStudent, String name, String major)
{
this.idStudent = idStudent;
this.name = name;
this.major = major;
classification = "";
}
// parameterized constructor 2
public Student(int idStudent,String name, String major, String classification)
{
this.idStudent = idStudent;
this.name = name;
this.major = major;
this.classification= classification;
}
// setters
public void setIdStudent(int idStudent)
{
this.idStudent = idStudent;
}
public void setName(String name)
{
this.name =name;
}
public void setMajor(String major)
{
this.major = major;
}
public void setClassification(String classification)
{
this.classification = classification;
}
//getters
public int getIdStudent()
{
return idStudent;
}
public String getName()
{
return name;
}
public String getMajor()
{
return major;
}
public String getClassification()
{
return classification;
}
}
//end of Student.java
//MainStudent.java
public class MainStudent {
public static void main(String[] args) {
// create an array of 4 Student object
Student students[] = new Student[4];
// initialize the objects
students[0] = new Student(160932,"Ghazal Ali","Science(Statistic)","Muda");
students[1] = new Student(167432,"Abdul Rahman","Engineering");
students[1].setClassification("Muda");
students[2] = new Student();
students[2].setIdStudent(174123);
students[2].setName("Abdul Majid");
students[2].setMajor("Forestry");
students[2].setClassification("Kecil");
students[3] = new Student(158911,"Hoo Yee An","Computer Science","Bongsu");
// output the details
for(int i=0;i<students.length;i++)
{
System.out.println(students[i].getIdStudent()+" "+students[i].getName()+" "+students[i].getMajor()+" "+students[i].getClassification());
}
}
}
//end of MainStudent.java
Output:
2. Create a class named Student that contains the following » idStudent. The idStudent is an...
java Write a class named Car that has the following fields: • yearModel: The yearModel field is an int that holds the car's year model. • make: The make field is a String object that holds the make of the car. • speed: The speed field is an int that holds the car's current speed. In addition, the class should have the following methods: • Constructor: The constructor should accept the car's year model and make as arguments. These values...
python Design a class named Car that has the following fields: yearModel: The yearModel field is an Integer that holds the car’s year model. make: The make field references a String that holds the make of the car. speed: The speed field is an Integer that holds the car’s current speed. In addition, the class should have the following constructor and other methods: Constructor: The constructor should accept the car’s year model and make as arguments. These values should be...
Java Program Write a class named Car that has the following fields: yearModel- The yearModel field is an int that holds the car’s year model. make- The make field is a String object that holds the make of the car, such as “Ford”, “Chevrolet”, etc. speed- This speed field is an int that holds the car’s current speed. In addition, the class should have the following methods: Constructor- The constructor should accept the car’s year model and make as arguments....
Using C++, Write a class named Employee that has the following member variables: name. A string that holds the employee's name. idNumber. An int variable that holds the employee's ID number. department. A string that holds the name of the department where the employee works. position. A string that holds the employee's job title. The class should have the following constructors: A constructor that accepts the following values as arguments and assigns them to the appropriate member variables: employee's name,...
2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...
C++ In the code cell below, define a class named Student with an integer id and a string name. This class should have a constructor that takes two arguments: one for the id and the other for the name. Then Create another class named CollegeStudent that publicly inherits from Student. This class should have a protected member named major. It should also have a constructor that takes three arguments: id, name, and major. This constructor should delegate initializing the id...
PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...
Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...
Room Class....... in JAVA!!!!! Write a class named Room that has the following fields: Length: Double variable that holds the rooms length(in feet). Breadth: The double variable that holds the rooms breadth(in feet). Height: Double variable that holds rooms height in feet. Color: String object that holds the color you want the room to be painted with. The class should have a constructor to initialize the fields for a particular instance (or object) of the class as given: All double...
Write a class named Month. The class should have an int field named monthNumber that holds the number of the month. For example. January would be 1. February would be 2. and so forth. In addition, provide the following methods A no-arg constructor that sets the monthNumber field to 1 A constructor that accepts the number of the month as an argument. It should set the monthNumber field to the value passed as the argument. If a value less than...