Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
assignments_new
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Suresh Kumar
assignments_new
Commits
bde6756e
Commit
bde6756e
authored
Jun 28, 2022
by
Suresh Kumar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abstraction-Polymorphism
parent
6c965654
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
0 deletions
+122
-0
Area.java
Abstraction_Polymorphsim/src/areacompile/com/Area.java
+37
-0
FindArea.java
Abstraction_Polymorphsim/src/arearuntime/com/FindArea.java
+63
-0
Employee.java
Abstraction_Polymorphsim/src/com/abstraction/Employee.java
+22
-0
No files found.
Abstraction_Polymorphsim/src/areacompile/com/Area.java
0 → 100644
View file @
bde6756e
package
areacompile
.
com
;
import
java.util.Scanner
;
public
class
Area
{
public
void
CalculateArea
(
double
radius
){
double
circle
=
(
3.14
*
radius
*
radius
);
System
.
out
.
println
(
"\n You Area Of Circle is................................("
+
circle
+
")\n"
);
}
public
void
CalculateArea
(
float
x
,
float
y
){
float
rectangle
=
x
*
y
;
System
.
out
.
println
(
"Your Area Of Rectangle is .....................................("
+
rectangle
+
")\n"
);
}
public
void
CalculateArea
(
double
length
,
double
width
){
double
triangle
=
length
*
width
;
System
.
out
.
println
(
"Area Of Triangle Is.....................................................("
+
triangle
+
")\n"
);
}
public
static
void
main
(
String
[]
args
){
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter radius For Circle ------ = "
);
double
radius
=
sc
.
nextDouble
();
System
.
out
.
print
(
"Enter Value_1 For Rectangle --------- = "
);
float
x
=
sc
.
nextFloat
();
System
.
out
.
print
(
"Enter Value_2 For Rectangle --------------= "
);
float
y
=
sc
.
nextFloat
();
System
.
out
.
print
(
"Enter Length For Triangle ------------------- = "
);
double
length
=
sc
.
nextDouble
();
System
.
out
.
print
(
"Enter Width For Triangle --------------------------= "
);
double
width
=
sc
.
nextDouble
();
Area
area
=
new
Area
();
area
.
CalculateArea
(
7
);
area
.
CalculateArea
(
3
,
3
);
area
.
CalculateArea
(
2.2
,
2.5
);
System
.
out
.
println
(
"------------------Compile_Time Polymorphism--------------------"
);
};
}
Abstraction_Polymorphsim/src/arearuntime/com/FindArea.java
0 → 100644
View file @
bde6756e
package
arearuntime
.
com
;
import
java.util.Scanner
;
class
Area
{
public
void
calculateArea
(){
// Empty----------------------Empty
}
}
class
AreaCircle
{
Scanner
i
=
new
Scanner
(
System
.
in
);
public
void
calculateArea
()
{
System
.
out
.
println
(
"Enter The Value Of Radius For The Calculate Area Of Circle ----------- = "
);
double
radius
=
i
.
nextDouble
();
double
pie
=
3.14
;
double
circle
=
pie
*
radius
*
radius
;
System
.
out
.
println
(
"Area Of Circle Is.............................. ("
+
circle
+
").\n"
);
}
}
class
Triangle
extends
Area
{
Scanner
ie
=
new
Scanner
(
System
.
in
);
public
void
calculateArea
(){
System
.
out
.
println
(
"Enter The Value_1 For The Calculate Area Of Triangle ----------- = "
);
double
length
=
ie
.
nextDouble
();
System
.
out
.
println
(
"Enter The Value_2 For The Calculate Area Of Triangle ----------- = "
);
double
width
=
ie
.
nextDouble
();
double
triangle
=
length
*
width
;
System
.
out
.
println
(
"Area Of Triangle Is................................................("
+
triangle
+
").\n"
);
}
}
class
Rectange
extends
Area
{
Scanner
s
=
new
Scanner
(
System
.
in
);
public
void
calculateArea
(){
System
.
out
.
println
(
"Enter The Value_1 For The Calculate Area Of Rectangle ----------- = "
);
float
x
=
s
.
nextFloat
();
System
.
out
.
println
(
"Enter The Value_21 For The Calculate Area Of Rectangle ----------- = "
);
float
y
=
s
.
nextFloat
();
float
rectangle
=
x
*
y
;
System
.
out
.
println
(
"Your Area Of Rectangle is ..................................................("
+
rectangle
+
").\n"
);
}
}
public
class
FindArea
extends
AreaCircle
{
public
void
calculateArea
()
{
System
.
out
.
println
(
"Ara Calculated"
);
}
public
static
void
main
(
String
[]
args
){
Scanner
sc
=
new
Scanner
(
System
.
in
);
AreaCircle
areacircle
=
new
AreaCircle
();
areacircle
.
calculateArea
();
Triangle
triangle
=
new
Triangle
();
triangle
.
calculateArea
();
Rectange
rectange
=
new
Rectange
();
rectange
.
calculateArea
();
System
.
out
.
println
(
"------------------Run_Time Polymorphism--------------------"
);
}
}
Abstraction_Polymorphsim/src/com/abstraction/Employee.java
0 → 100644
View file @
bde6756e
package
com
.
abstraction
;
import
java.util.Scanner
;
abstract
class
Person
{
abstract
void
detail
();
}
public
class
Employee
extends
Person
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
@Override
void
detail
(){
System
.
out
.
print
(
"Enter Your First Full With White Space---------Eg(Suresh Kumar)-----("
);
String
name
=
sc
.
nextLine
();
System
.
out
.
print
(
"Enter Your Full Address---------Eg(H_No #12 Stree No #3 Umerkot Sindh Pakistn)-----("
);
String
full_address
=
sc
.
nextLine
();
System
.
out
.
println
(
"Your Name is Mr------("
+
name
+
") "
+
"\n"
+
"You Address is ------("
+
full_address
+
")"
);
}
public
static
void
main
(
String
[]
args
){
Employee
employee
=
new
Employee
();
employee
.
detail
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment