forked from Hnoianko/prog.kiev.ua-JavaOOP-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c5d6ab4
Showing
3 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Homework1.1.iml | ||
.idea/ | ||
out/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.gmail.gnoianko; | ||
|
||
public class Cat { | ||
private String name; | ||
private int age; | ||
private double weight; | ||
private String coatColor; | ||
|
||
public Cat(String name, int age, double weight, String coatColor) { | ||
this.name = name; | ||
this.age = age; | ||
this.weight = weight; | ||
this.coatColor = coatColor; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getAge() { | ||
return age; | ||
} | ||
|
||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
public double getWeight() { | ||
return weight; | ||
} | ||
|
||
public void setWeight(double weight) { | ||
this.weight = weight; | ||
} | ||
|
||
public String getCoatColor() { | ||
return coatColor; | ||
} | ||
|
||
public void setCoatColor(String coatColor) { | ||
this.coatColor = coatColor; | ||
} | ||
|
||
public void voice() { | ||
System.out.println("Hello world ;)"); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Cat{" + | ||
"name='" + name + '\'' + | ||
", age=" + age + | ||
", weight=" + weight + | ||
", coatColor='" + coatColor + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.gmail.gnoianko; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
Cat catOne = new Cat("Bobik", 4, 4.5, "Black"); | ||
catOne.voice(); | ||
System.out.println(catOne); | ||
catOne.setCoatColor("White"); | ||
System.out.println(catOne); | ||
} | ||
} |