Skip to content

Commit 4d99a60

Browse files
inheritance practice
1 parent 91551ae commit 4d99a60

File tree

11 files changed

+78
-0
lines changed

11 files changed

+78
-0
lines changed

Inheritence/.vscode/launch.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Launch Current File",
10+
"request": "launch",
11+
"mainClass": "${file}"
12+
},
13+
{
14+
"type": "java",
15+
"name": "Launch TestProject",
16+
"request": "launch",
17+
"mainClass": "com.mycompany.testproject.TestProject",
18+
"projectName": "TestProject"
19+
}
20+
]
21+
}

Inheritence/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.mycompany</groupId>
5+
<artifactId>TestProject</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>11</maven.compiler.source>
11+
<maven.compiler.target>11</maven.compiler.target>
12+
<exec.mainClass>com.mycompany.testproject.TestProject</exec.mainClass>
13+
</properties>
14+
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.mycompany.testproject;
2+
3+
public class Admin extends Employee {
4+
5+
public Admin(String name, double salery) {
6+
super(name, 0, salery);
7+
}
8+
9+
void showDetails() {
10+
System.out.println("Name: " + name + " Salery: " + salery);
11+
}
12+
13+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.mycompany.testproject;
2+
3+
public class Employee {
4+
String name;
5+
int age;
6+
double salery;
7+
8+
public Employee(String name, int age, double salery) {
9+
this.name = name;
10+
this.age = age;
11+
this.salery = salery;
12+
}
13+
14+
void showDetails() {
15+
System.out.println("Name: " + name + " Age: " + age + " Salery: " + salery);
16+
}
17+
18+
}
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.mycompany.testproject;
2+
3+
public class TestProject {
4+
public static void main(String[] args) {
5+
Employee e1 = new Employee("John", 25, 1000);
6+
e1.showDetails();
7+
Admin a1 = new Admin("Jane", 1000);
8+
a1.showDetails();
9+
}
10+
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
com/mycompany/testproject/TestProject.class

0 commit comments

Comments
 (0)