Skip to content

Instantly share code, notes, and snippets.

@FreeFly19
Created November 15, 2016 20:10
Show Gist options
  • Select an option

  • Save FreeFly19/1c09a5865b2c48144a4d40fcc2fb00fc to your computer and use it in GitHub Desktop.

Select an option

Save FreeFly19/1c09a5865b2c48144a4d40fcc2fb00fc to your computer and use it in GitHub Desktop.
Class work #6 ex2
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);
}
}
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