1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
erik [133]
1 year ago
15

define the student class to inherit from the person class. declare an int public class variable to represent the id number. do n

ot make this variable private. name this variable id. write the constructor to initialize all class variables. the order of the student constructor should be (firstname, lastname, id). also, define the tostring() method to resemble the tostring() method from the person class, except with the id following the name. the format should resemble: student: firstname lastname id make sure to add/create a .equals(object obj) method for person, and student. a student id is unique, so students are equal if the id is equal, along with their first and last names. for people, they are only unique/equal if both first and last names are equal. step 2: roster.initializelistfromfile() now, complete the unfinished initializelistfromfile() in the roster class. this method takes a filename as a parameter and fills the arraylist of objects of type person or student. each line in the file to read from represents a single object with the following possible formats: for a student object: firstname lastname id for a person object: firstname lastname your method should loop through every line in the file, and add a new person or student object to the people arraylist by calling the appropriate constructor with the appropriate arguments.
Computers and Technology
1 answer:
WINSTONCH [101]1 year ago
7 0
<h3>What is the code for roster?</h3>

//Roster.java  import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner;  public class Roster {      ArrayList<Person> people;     ArrayList<Student> students;       public Roster(String filename ) {         people = new ArrayList<Person>();         students = new ArrayList<Student>();         initializeListFromFile(filename);     }      public void initializeListFromFile(String filename) {         try {             Scanner scnr = new Scanner(new File(filename));             while (scnr.hasNextLine())              {                 String tmp = scnr.nextLine();                 String[] li = tmp.split(" ");                 if(li.length == 3)                 {                     // Student Object                     students.add(new Student(li[0], li[1], Integer.parseInt(li[2])));                                  }                 else if(li.length == 2)                 {                     // Person Object                     people.add(new Person(li[0],li[1]));                 }                 else                 {                     System.out.println("Invalid entry in file: " + filename);                     System.exit(1);                 }             }             scnr.close();         } catch (FileNotFoundException e) {             e.printStackTrace();         }     }      public static void main(String [] args) {         Roster r = new Roster("test.txt");         System.out.println(r.people);         System.out.println(r.students);     }  }

To learn more about code, refer to

brainly.com/question/26134656

#SPJ4

You might be interested in
What does % find on edhesive??
statuscvo [17]

Answer:

Explanation: What is that word you typed?

3 0
3 years ago
Give an efficient algorithm to find all keys in a min heap that are smaller than a provided valueX. The provided valuedoes notha
OlgaM077 [116]

Answer:

Starting from root, recursively traverse the min-heap. Once we find a key with value less than our X, we know that every key in subtree of that key will be also smaller than our X. Otherwise, we should keep traversing.

Explanation:

The complexity of this algorithm will be O(N) where N is the number of keys in our min-heap.

3 0
3 years ago
Describe how web caching can reduced the delay in receiving a requested object .Will web caching reduce the delay for all object
nydimaria [60]

Answer:

Web caching can bring the desired content "closer" to the user, perhaps to the same LAN to which the user's host is connected. Web caching can reduce the delay for all objects, even objects that are not cached, since caching reduces the traffic on links

Explanation:

8 0
3 years ago
If an organization’s DNS server can resolve a DNS request from its own cache, the DNS server is said to be ____.
abruzzese [7]

Answer:

Answered below

Explanation:

The DNS server is said to be a caching-only DNS server.

A caching-only Domain Name System server, works by recieving queries from the client, proceeds to perform queries against other named servers, then caches the results and returns the results to the client.

Subsequent queries are resolved and returned for the specified host straight from the the cache, by the server, instead of submitting to the external server.

The advantage of this process is that it reduces traffic from outgoing DNS and speeds up the name resolution. Also, there is a reduction in the amount of query traffic.

6 0
3 years ago
Which option can Jesse use to customize her company’s logo, name, address, and similar details in all her business documents?
Rasek [7]
Are you talking about word processors? If yes, you can edit a document's header and footer so the change reflects on all pages of the document.
3 0
3 years ago
Other questions:
  • Repetition learning rates are the same for everyone, so there is no need to find an activation and break pattern that works
    12·2 answers
  • I need help RIGHT NOW PLZ!!!!!!!!!!!!! this is due in 5 mins
    13·1 answer
  • What is an image that you can apply to another image to add detail and texture?
    6·1 answer
  • List and briefly defined categories of security services.
    8·1 answer
  • How to delete a virus that act by restarting u r computer? I am in safe mood to aviod restart.
    10·1 answer
  • Read the Security Guide about From Anthem to Anathema on pages 238-239 of the textbook. Then answer the following questions in t
    14·1 answer
  • Your company wants to use an IoT device but wants to make sure it does not interfere with other RF devices that use the 2.4 GHz
    13·1 answer
  • Write a loop that reads positive integers from standard input and that terminates when it reads an integer that is not positive.
    8·1 answer
  • द्विआधार जोड गर (Binary<br>addition):<br>-<br>(i) 1012 + 1112<br>(ii) 1112 + 100​
    15·1 answer
  • Write and test a program that computes the area of a circle. This program should request a number representing a radius as input
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!