Question

USING JAVA,

Class Design: Person The Person class is intended to be an abstract and simplified representation of a person. Each person wi

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 public class Person t 2 $ja Per pub 4 private Person friends; private String name; public Person String name) 10 12 setName41 42 Person anotherPerson (Person) o; return anotherPerson.name.equalsIgnoreCase(this.name); 45 47 50 return false; 51 52 5382 83 if (friends index]-null) £ if (friends [index].equals(friend))5 85 86 87 System.out.println(friend.name+ already exis121 int size -0; 122 123 124 125 126 127 128 129 int index0fFriend 1; for (int index - 0; index < friends.length; index++) i156 157 for (int index = index0fFriend; index <= size - 2; index++) { $javac Person Person.java:4: public static 158 159 frie199 if(friendCount-)t 200 201 System.out.println( There are no friends for +name); 202 203 204 205 206 207 208 209 210 211 2

Add a comment
Know the answer?
Add Answer to:
USING JAVA, Class Design: Person The Person class is intended to be an abstract and simplified representation of a pers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Pls Class Design: Donut (Suggested Time Spent: < 15 minutes) The Donut class is intended to be an abstract a...

    In Java Pls Class Design: Donut (Suggested Time Spent: < 15 minutes) The Donut class is intended to be an abstract and simplified representation of a yummy edible donut Class Properties (MUST be private) Name of the donut Type of donut Price of the donut Class Invariants Donut name must not be empty (Default: "Classic") Type of donut can only be one of the following: "Plain," "Filled," or "Glazed" (Default: "Plain") Class Components Public Getter and Private Setter for name,...

  • In Java PLS HW7: Feature Comparison CSS 142 Computer Programming 1 By: Hansel Ong Summary With so many options for most...

    In Java PLS HW7: Feature Comparison CSS 142 Computer Programming 1 By: Hansel Ong Summary With so many options for most anything nowadays (phones, cars, hotels, schools, courses, etc.) consumers have become accustomed to selecting a few objects (e.g. smart watches) to compare the features. Write a simple "Device" class with a few features that could be used to compare Device instances and a Driver class with which to test/drive this "Device" class. Skills Expected All the skills from previous...

  • PLEASE DO IN JAVA 1) Create interface named “Person” which exposes getter/setter methods for the person’s...

    PLEASE DO IN JAVA 1) Create interface named “Person” which exposes getter/setter methods for the person’s name and college ID: 1. getName 2. setName 3. getID 4. setID. The college ID is represented as “int”. Define two classes, Student and Faculty, which implement Person. Add field GPA to Student and department to faculty. Make them private and create corresponding getters (getGPA, getDepartment) and setters (setGPA, setDepartment). Use appropriate types. 2) Write a class College, which contains the name of the...

  • Ticket Hierarchy Ticket Abstract Class Create a static variable called nextTicketId. This is an integer representing...

    Ticket Hierarchy Ticket Abstract Class Create a static variable called nextTicketId. This is an integer representing the next available integer for the ticketId                                 private static int nextTicketId = 1000; getPrice method: Abstract method that returns a double. NOTE: Do not make price an instance variable in Ticket. Noargument constructor: Sets event name to “none”, event location to “none”, and ticket id to 0. Create a constructor that accepts the event name and event location as parameters. Set the ticket Id...

  • College of Winston and Charlotte This program will calculate the amount for a semester bill at...

    College of Winston and Charlotte This program will calculate the amount for a semester bill at The College of Winston and Charlotte. Part 1: Create a class Course.java: The class has non-static instance variables: private String department private int courseNumber private int courseCredits private double courseCost The class must have a default constructor which will set values as follows: department = “unknown” courseNumber = 0 courseCost = 0 courseCredits = 0 The class must have a non-default constructor which will...

  • Writing 3 Java Classes for Student registration /** * A class which maintains basic information about...

    Writing 3 Java Classes for Student registration /** * A class which maintains basic information about an academic course. */ public class Course {    /** * Attributes. */ private String code; private String title; private String dept; // name of department offering the course private int credits; /** * Constructor. */ public Course(String code, String title, int credits) { // TODO : initialize instance variables, use the static method defined in // Registrar to initialize the dept name variable...

  • Exercise 1: Adding a Test Harness to the Person class To make it easier to test...

    Exercise 1: Adding a Test Harness to the Person class To make it easier to test code that you have written for a Java class you can add to that class a main method that acts as a "test harness". A test harness is a main method that includes calls to methods that you wish to test. For convention this main method is the last method of the class. If you have a test harness, you do not need to...

  • Java Object Array With 2 Elements In 1 Object

    1. Create a UML diagram to help design the class described in Q2 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Person class object; should they be private or public? Determine what class methods are required; should they be private or public?2. Write Java code for a Person class. A Person has a name of type String and an age of type integer.Supply two constructors: one will be...

  • Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains...

    Chapter 5 Assignment Read directions: In JAVA design and implement a class called Dog that contains instance data that represents the dog's name and dog's age. Define the Dog constructor to accept and initialize instance data. Include getter and setter methods for the name and age. Include a method to compute and return the age of the dog in "person years" (seven times age of dog. Include a toString method that returns a one-time description of the dog (example below)....

  • In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program...

    In Java Code Needed is Below the Question Using Program 3: Encapsulating Dogs, modify this program to create a database of dogs of your own. You will also include File I/O with this program. You will create 3 classes for this assignment. The first class: Create a Class representing the information that is associated with one item (one dog) of your database. Name this class Dog. Using Lab 3, this will include the information in regard to one dog. The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT