Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package opgave1;
- import java.util.Scanner;
- public class Hoofd {
- public static void main(String[] args) {
- Group students = createGroup();
- fill(students);
- change(students);
- }
- private static void change(Group students) {
- System.out.println("De groep bevat nu: \n" + students.toString());
- System.out.println("Please enter a student's number, as well as their new"
- + "first and last name, separated by commas");
- Scanner scanner = new Scanner(System.in);
- String[] results = scanner.nextLine().split(", ");
- if (Integer.parseInt(results[0]) >= 0) {
- students.setName(Integer.parseInt(results[0]), results[1], results[2]);
- change(students);
- }
- }
- private static void fill(Group group) {
- Scanner scanner = new Scanner(System.in);
- for (int i = 0 ; i < group.getSize() ; i++)
- {
- System.out.print("Please enter a first name, last name, and number for group member number " + i
- + ", separated by commas");
- String[] results = scanner.nextLine().split(", ");
- Student s = new Student(results[0], results[1], Integer.parseInt(results[2]));
- group.add(s);
- }
- }
- private static Group createGroup() {
- Scanner scanner = new Scanner(System.in);
- System.out.println("How large a group of students would you like to make?");
- int size = scanner.nextInt();
- Group result = new Group(size);
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement