Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8c399aa

Browse files
solved all problems
0 parents commit 8c399aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+919
-0
lines changed

‎AllInOnePrinter.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class AllInOnePrinter implements Printable, Scannable {
2+
@Override
3+
public void print() {
4+
System.out.println("All in one print");
5+
}
6+
@Override
7+
public void scan() {
8+
System.out.println("All in one scan");
9+
}
10+
}

‎Animal.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public abstract class Animal {
2+
public abstract void makeSound();
3+
4+
}

‎Author.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
public class Author {
2+
private String name;
3+
private String age;
4+
private String gender;
5+
6+
public Author(String name, String age, String gender) {
7+
setAge(age);
8+
setGender(gender);
9+
setName(name);
10+
}
11+
12+
public String getName() {
13+
return name;
14+
}
15+
16+
public void setName(String name) {
17+
this.name = name;
18+
}
19+
20+
public String getAge() {
21+
return age;
22+
}
23+
24+
public void setAge(String age) {
25+
this.age = age;
26+
}
27+
28+
public String getGender() {
29+
return gender;
30+
}
31+
32+
public void setGender(String gender) {
33+
this.gender = gender;
34+
}
35+
}

‎BankAccount.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
public class BankAccount {
2+
private int accountNumber;
3+
private double balance;
4+
private String accountHolder;
5+
6+
public BankAccount(int accountNumber, double balance, String accountHolder) {
7+
setAccountHolder(accountHolder);
8+
setAccountNumber(accountNumber);
9+
setBalance(balance);
10+
}
11+
12+
public int getAccountNumber() {
13+
return accountNumber;
14+
}
15+
16+
public double getBalance() {
17+
return balance;
18+
}
19+
20+
public String getAccountHolder() {
21+
return accountHolder;
22+
}
23+
24+
public void setAccountNumber(int accountNumber) {
25+
this.accountNumber = accountNumber;
26+
}
27+
28+
public void setBalance(double balance) {
29+
this.balance = balance;
30+
}
31+
32+
public void setAccountHolder(String accountHolder) {
33+
this.accountHolder = accountHolder;
34+
}
35+
36+
public void deposit(double amount) {
37+
balance+=amount;
38+
}
39+
40+
public void withdraw(double amount) {
41+
if(amount <= balance) balance-=amount;
42+
}
43+
}

‎Book.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
public class Book {
2+
private String title;
3+
private String year;
4+
private Author author;
5+
6+
public Book(String title, String year, Author author) {
7+
setAuthor(author);
8+
setTitle(title);
9+
setYear(year);
10+
}
11+
12+
public String getTitle() {
13+
return title;
14+
}
15+
16+
public void setTitle(String title) {
17+
this.title = title;
18+
}
19+
20+
public String getYear() {
21+
return year;
22+
}
23+
24+
public void setYear(String year) {
25+
this.year = year;
26+
}
27+
28+
public Author getAuthor() {
29+
return author;
30+
}
31+
32+
public void setAuthor(Author author) {
33+
this.author = author;
34+
}
35+
36+
public void displayDetails() {
37+
System.out.println("Title: " + title);
38+
System.out.println("Year: " + year);
39+
System.out.println("Author: " + author.getName());
40+
}
41+
}

‎Calculator.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
public class Calculator {
2+
public int divide(int dividend, int divisor) throws DivideByZeroException {
3+
4+
// try {
5+
// result = dividend/divisor;
6+
// }
7+
//
8+
// catch (ArithmeticException e) {
9+
// System.out.println(e);
10+
// }
11+
12+
if(divisor==0)
13+
throw new DivideByZeroException("Divisor should not be Zero");
14+
15+
int result = dividend/divisor;
16+
17+
return result;
18+
}
19+
}

‎Car.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class Car extends Vehicle{
2+
@Override
3+
public void displayInfo() {
4+
super.displayInfo();
5+
System.out.println("I am a car");
6+
}
7+
}

‎Cat.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Cat extends Animal implements Swim{
2+
public void makeSound() {
3+
System.out.println("Cat Meows!");
4+
}
5+
6+
public void swim() {
7+
System.out.println("Cat can not swim");
8+
}
9+
}

‎Child.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Child extends Parent {
2+
public static void displayInfo() {
3+
System.out.println("Static method in Child class.");
4+
}
5+
6+
public void showInfo() {
7+
System.out.println("Instance method in Child class");
8+
}
9+
10+
}

‎Circle.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
public class Circle extends Shape{
2+
public final double PI = 3.1416;
3+
4+
public double radius;
5+
6+
public Circle(double radius) {
7+
this.radius = radius;
8+
}
9+
10+
@Override
11+
public double calculateArea() {
12+
return PI * radius * radius;
13+
}
14+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /