-
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
1 parent
89abd48
commit 5f5e58f
Showing
2 changed files
with
27 additions
and
6 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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
public class FirstClass { // [1] | ||
public static void main(String[] args) { // [2] | ||
System.out.println("Hello from FirstClass!"); // [3] | ||
|
||
String greeting = "Hello from FirstClass!"; | ||
System.out.println(greeting); | ||
public class FirstClass { | ||
public static void main(String[] args) { | ||
Notebook notebook = new Notebook(600, 1000); | ||
System.out.println(notebook.weight + " " + notebook.price); | ||
notebook.checkPrice(); | ||
Notebook heavyNotebook = new Notebook(2000, 1500); | ||
System.out.println(heavyNotebook.weight + " " + heavyNotebook.price); | ||
heavyNotebook.checkPrice(); | ||
Notebook oldNotebook = new Notebook(1600, 500); | ||
System.out.println(oldNotebook.weight + " " + oldNotebook.price); | ||
oldNotebook.checkPrice(); | ||
} | ||
} |
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,16 @@ | ||
public class Notebook { | ||
int weight; | ||
int price; | ||
public Notebook(int weight, int price) { | ||
this.weight = weight; | ||
this.price = price; | ||
} | ||
|
||
public void checkPrice() { | ||
if (price < 900) { | ||
System.out.println("This notebook is cheap"); | ||
} else { | ||
System.out.println("This notebook is quite expensive"); | ||
} | ||
} | ||
} |