Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package introToclasses; 1 * * A class is a blueprint describing objects in terms of the data they have and the methods that can be

package introToclasses;
1**
A class is a blueprint describing objects in terms of the data they have and the methods that can be acted on them. The methods change the objects data.
The data is anything that describes the object (up to you)
Methods are (C functions) but can only be called (invoked) on an object
and they can change the attributes (values of those variables) of that object
To create an object, we instantiate the class (we create an istance of the class)
ClassName objectName = new ClassName(params);
ClassName acts as a new type
Let's create a class for course
Always name your classes with the first letter capital */
public class Course {
String name;
String instructor;
int numberstudents;
String description;
int credits;
//a mthod to display the values of all these variables:
void print(){
System.out.println("Name: "+
this.name);
System.out.println("Instructor: "+ this.instructor);
System.out.println ("Credits: "+ this.credits);
System.out.println("Number registered: "+ this.numberstudents);
}
System.out.println("Decription: "+ this.description);
void addStudent (){
//increment number student. Always use this.variableName
//will later why.
System.out.println("Adding one student to "+
this.name);
}
this. numberstudents++;
void dropstudent(){
System.out.println("Dropping one student from "+
this.name);
} this numberstudents--;
//Design a method to change the instructor's name, with a new name.
// changeInstructor accepts a string as the new name.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Compare and contrast verbal and nonverbal codes

Answered: 1 week ago

Question

Define and discuss the nature of ethnocentrism and racism

Answered: 1 week ago

Question

Define and discuss racial and ethnic stereotypes across cultures

Answered: 1 week ago