Created
November 15, 2016 20:10
-
-
Save FreeFly19/1c09a5865b2c48144a4d40fcc2fb00fc to your computer and use it in GitHub Desktop.
Class work #6 ex2
This file contains hidden or 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
| import java.util.Scanner; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Table stol = createTable(); | |
| printTableInfo(stol); | |
| } | |
| private static Table createTable() { | |
| Scanner scanner = new Scanner(System.in); | |
| Table t = new Table(); | |
| System.out.print("Please enter model of new table: "); | |
| t.model = scanner.nextLine(); | |
| System.out.print("Please enter сolor of new table: "); | |
| t.color = scanner.nextLine(); | |
| System.out.print("Please enter weight of new table: "); | |
| t.weight = scanner.nextInt(); | |
| return t; | |
| } | |
| private static void printTableInfo(Table table) { | |
| System.err.println("Model: " + table.model); | |
| System.err.println("Color: " + table.color); | |
| System.err.println("Weight: " + table.weight); | |
| } | |
| } |
This file contains hidden or 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
| public class Table { | |
| String color = "White"; | |
| int weight = 1000; | |
| String model; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment