Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tutorial_repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Syed Naqvi
tutorial_repo
Commits
faec20a5
Commit
faec20a5
authored
1 month ago
by
Syed Naqvi
Browse files
Options
Downloads
Patches
Plain Diff
code skeleton - Ex-W6
parent
db3a7bcc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Ex-w6/ums.java
+99
-0
99 additions, 0 deletions
Ex-w6/ums.java
with
99 additions
and
0 deletions
Ex-w6/ums.java
0 → 100644
+
99
−
0
View file @
faec20a5
package
org.example
;
// Abstract superclass
abstract
class
Person
{
protected
String
name
;
protected
int
age
;
public
Person
(
String
name
,
int
age
)
{
this
.
name
=
name
;
this
.
age
=
age
;
}
public
void
greet
()
{
System
.
out
.
println
(
"Hello, I am a member of the university."
);
}
public
abstract
void
displayDetails
();
}
// Student subclass
class
Student
extends
Person
{
protected
String
studentID
;
public
Student
(
String
name
,
int
age
,
String
studentID
)
{
super
(
name
,
age
);
this
.
studentID
=
studentID
;
}
@Override
public
void
displayDetails
()
{
System
.
out
.
println
(
"Student Details: Name: "
+
name
+
", Age: "
+
age
+
", ID: "
+
studentID
);
}
public
void
study
()
{
System
.
out
.
println
(
"Student is studying."
);
}
}
// Professor subclass
class
Professor
extends
Person
{
protected
String
specialization
;
public
Professor
(
String
name
,
int
age
,
String
specialization
)
{
super
(
name
,
age
);
this
.
specialization
=
specialization
;
}
@Override
public
void
displayDetails
()
{
System
.
out
.
println
(
"Professor Details: Name: "
+
name
+
", Age: "
+
age
+
", Specialization: "
+
specialization
);
}
public
void
teach
()
{
System
.
out
.
println
(
"Professor is teaching."
);
}
}
// Staff subclass
class
Staff
extends
Person
{
protected
String
department
;
public
Staff
(
String
name
,
int
age
,
String
department
)
{
super
(
name
,
age
);
this
.
department
=
department
;
}
@Override
public
void
displayDetails
()
{
System
.
out
.
println
(
"Staff Details: Name: "
+
name
+
", Age: "
+
age
+
", Department: "
+
department
);
}
public
void
work
()
{
System
.
out
.
println
(
"Staff member is working."
);
}
}
// Main class
public
class
ums
{
public
static
void
main
(
String
[]
args
)
{
Student
student
=
new
Student
(
"Alice"
,
20
,
"S12345"
);
Professor
professor
=
new
Professor
(
"Dr. Smith"
,
45
,
"Computer Science"
);
Staff
staff
=
new
Staff
(
"Mr. Brown"
,
35
,
"Administration"
);
student
.
greet
();
student
.
displayDetails
();
student
.
study
();
System
.
out
.
println
();
professor
.
greet
();
professor
.
displayDetails
();
professor
.
teach
();
System
.
out
.
println
();
staff
.
greet
();
staff
.
displayDetails
();
staff
.
work
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment