Write a class contactInfo to store contact information for a person. It should have attributes for a person’s name, business phone, home phone, cell phone, e-mail address, and home address. It should have a toString method that returns this data as a string, making appropriate replacements for any attributes that do not have values. It should have a constructor contactInfo (aString) that creates and returns a new instance of the class, using data in the string aString. The constructor should use a format consistent with what the toString method produces.
Using a text editor, create a text file of contact information, as described in the previous paragraph, for several people. Write a program that reads this file, displays the data on the screen, and creates an array whose base type is ContactInfo. Allow the user to do one of the following: change some data in one contact, add a contact, or delete a contact. Finally, write over the file with the modified contacts.
Want to see the full answer?
Check out a sample textbook solutionChapter 10 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Additional Engineering Textbook Solutions
Mechanics of Materials (10th Edition)
Database Concepts (8th Edition)
Management Information Systems: Managing The Digital Firm (16th Edition)
Starting Out With Visual Basic (8th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Introduction To Programming Using Visual Basic (11th Edition)
- B - RobotFriend Create a RobotFriend class. RobotFriend is a new toy just on the market. Copy the starter class and the tester from Codecheck. A RobotFriend has a name and replies to various commands Provide a constructor that takes the name of the RobotFriend as a parameter. Remember that a constructor has the same name as the class. What does the class need to remember? That is the instance variable. Provide the following methods: public String getName () gets the name of this RobotFriend • public void setName (String newName) sets a new name for this RobotFriend • public String whatDoYouNeed () returns a string consisting of name + needs a battery charge" where name is the name of this RobotFriend (which was supplied in the constructor) public String doCommand (String whatToDo) returns a string consisting of "Your friend " + name + does not + whatToDo where name is the name of this RobotFriend and whatToDo is the parameterarrow_forwardDesign a class named MyPoint to represent a point withx- and y-coordinates. The class contains:■■ The data fields x and y that represent the coordinates with getter methods.■■ A no-arg constructor that creates a point (0, 0).■■ A constructor that constructs a point with specified coordinates.■■ A method named distance that returns the distance from this point to aspecified point of the MyPoint type.■■ A method named distance that returns the distance from this point toanother point with specified x- and y-coordinates.■■ A static method named distance that returns the distance from two MyPointobjects.Draw the UML diagram for the class then implement the class. Write a testprogram that creates the two points (0, 0) and (10, 30.5) and displays the distancebetween them.arrow_forwardDesign a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes these values and the appropriate mutator and accessor methods for the class's fields. Demonstrate the Customer class in a program that prompts the user to enter values for the customer's name, address, phone number, and customer number, and then asks the user whether or not the customer wants to receive mail. Use this information to create a customer object and then print its information. Put all of your classes in the same file. To do this, do not declare them public. Instead, simply write: class Person…arrow_forward
- The class "Car" has the following attributes: plate (String), mark (String), model (String), year (int), km (int).Write a constructor method for the "Car" class that takes values as parameters for all these attributes.arrow_forwardDesign a class named MyInteger. The class contains: ■ An int data field named value that stores the int value represented by this object. ■ A constructor that creates a MyInteger object for the specified int value. ■ A get method that returns the int value. ■ The methods isEven(), isOdd(), and isPrime() that return true if the value in this object is even, odd, or prime, respectively. ■ The static methods isEven(int), isOdd(int), and isPrime(int) that return true if the specified value is even, odd, or prime, respectively. ■ The static methods isEven(MyInteger), isOdd(MyInteger), and isPrime(MyInteger) that return true if the specified value is even, odd, or prime, respectively. ■ The methods equals(int) and equals(MyInteger) that return true if the value in this object is equal to the specified value. ■ A static method parseInt(char[]) that converts an array of numeric characters to an int value. ■ A static method parseInt(String) that converts a string into an int value. Draw the UML…arrow_forwardjava. Check ‘n Shop is a grocery supermarket in South Africa that provides a loyalty program to customers on a monthly basis. Customers earn points based on the number of visits and the amount they spend, especially on healthy foods during the month. The private data fields for the Shopper object class are: See attached image The constructor must assign values of the parameters to the private data field variables. The static variable should be incremented by one in the constructor. The increaseLoyaltyPoints() method calculates the number of loyalty points based on the amount a customer spent at the supermarket. All customers receive 100 free points each month. Use the following criteria to calculate the additional points earned to be added to the 100 free points: For every four rands (R4) spent, one loyalty point is awarded. Make use of an appropriate Math class function to round up the loyalty points to a whole number. The updateHealthLevel() method receive the total amount…arrow_forward
- Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name (a string) to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g…arrow_forwardCreate a class that represents an employee. This class will have three constructors to initialize variables. If the constructor doesn't provide a parameter for a field, make it either "(not set)" or "0" as appropriate. Name: Employee Fields: - name : String - idNumber : int - department : String - position : String Methods: + Employee() + Employee(name : String, idNumber : int) + Employee(name : String, idNumber : int, department : String, position : String) + getName() : String + getDepartment() : String + getPosition() : String + getIdNumber() : intEmployeeDemo.java Code public class EmployeeDemo{public static void printInfo(Employee e){System.out.println(e.getName() + ", " + e.getIdNumber() + ", " + e.getDepartment() + ", " + e.getPosition());}public static void main(String[] args){Employee e1 = new Employee();Employee e2 = new Employee("Bill Gates", 1975);Employee e3 = new Employee("Steve Jobs", 1976, "Design",…arrow_forwardCreate a class that represents an employee. This class will have three constructors to initialize variables. If the constructor doesn't provide a parameter for a field , make it either "(not set)" or "0" as appropriate. Name: Employee Fields : - name : String - idNumber : Int - department : String - position : String Methods: + Employee() + Employee(name : String, idNumber : int) + Employee(name : String, idNumber : int, department : String, position : String) + getName() : String + getDepartment() : String + getPosition() : String + getIdNumber() : int Write in java and use test case #1 as an example.arrow_forward
- Design a class named MyInteger. The class contains:■■ An int data field named value that stores the int value represented bythis object.■■ A constructor that creates a MyInteger object for the specified int value.■■ A getter method that returns the int value.■■ The methods isEven(), isOdd(), and isPrime() that return true if thevalue in this object is even, odd, or prime, respectively.■■ The static methods isEven(int), isOdd(int), and isPrime(int) thatreturn true if the specified value is even, odd, or prime, respectively.■■ The static methods isEven(MyInteger), isOdd(MyInteger), andisPrime(MyInteger) that return true if the specified value is even, odd,or prime, respectively.■■ The methods equals(int) and equals(MyInteger) that return true ifthe value in this object is equal to the specified value.■■ A static method parseInt(char[]) that converts an array of numericcharactersto an int value.■■ A static method parseInt(String) that converts a string into an int value.Draw the UML…arrow_forwardDesign a class named Person with properties for holding a person’s name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether the customer wishes to be on a mailing list. Demonstrate an object of the Customer class in a simple application.arrow_forward1. for this question do not write the code just explain how you would Create a class called Elevator that can be moved between floors in an N-storey building. Elevator uses a constructor to initialize the number of floors (N) in the building when the object is instantiated. Elevator also has a default constructor that creates a five- (5) storey building. The Elevator class has a termination condition that requires the elevator to be moved to the main (i.e., first) floor when the object is cleaned up. Write a finalize() method that satisfies this termination condition and verifies the condition by printing a message to the output, Elevator ending: elevator returned to the first floor. In main(), test at least five (5) possible scenarios that can occur when Elevator is used in a building with many floors (e.g., create, move from one floor to another, etc.). Hint: Termination occurs when the instance is set to null. You may wish to investigate “garbage collection” for this exercise.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,