Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java**** A .txt file is given with students of 500 names. For group activities, you must have a seating arrangement of either 3 or 4

Java**** A .txt file is given with students of 500 names.

For group activities, you must have a seating arrangement of either 3 or 4 persons per table. It is not allowed to have a table with only 1 or 2 persons seated. Design a class, Table, that will be used to create table objects. Associated with each table object will be 3 or 4 person objects, created from a class Person. For the Person class, there is a name associated with a person. The name will read from the file 500names.txt The Person class should define at least one constructor, get and set methods, and a method that returns the length of the persons name. You may decide to store the first and last names as separate fields, but that is up to you.

For the Table class, there are a number of persons associated with each table. There should be at least one constructor defined, getter and setter methods, and a toString method (see page 170) that prints the names of all persons seated at a table.

You will be reading the student names from the file 500names.txt. We will cover the mechanism for doing that in class, or you can read ahead to figure out how to read the names from the file using the Scanner class.

For now, your application should read 32 names from the file, assign them to tables, and print out the names assigned to each table:

I have a mess.... and just need some direction.

//The java class FilesProgram to locate our 500names.txt file

import java.io.File;

//Declare the class.

public class Person {

//Data members.

private String name;

//Constructor

public Person (){

//Unasssigned so we can give it value

name = "Unassigned";

}

//Returns the name of the student

public String getName1() {

return name;

}

//Assign the first name of the student.

public static void setName(String personName) {

public person() {

name + null;

public String getName() {

}

//Location to find file.

String filename="500names.txt";

//Making the tables.

//data members.

String studentName;

private int tableNumber;

//Constructor

public Table(String studentName, int tableNumber ) {

name = personName;

number = personTable;

public static void

//need a for loop for table allocation

for

name1 = personName1

name2 = personName2

name3 = personName3

name4 = personName4

}

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What consequences are you avoiding?

Answered: 1 week ago

Question

What is the most common attribute that you identified to evaluate?

Answered: 1 week ago