Explanation of Solution
Given: The mail-system project.
To find: The steps to create an object of class MailServer and then create two objects of class MailClient and set the name of instance as sophie and juan. The name of the user in the MailClient should be “Sophie� and “Juan�. After that, invoke the method named sendMailItem of Sophie’s instance in order to send the message to the user named Juan.
Solution:
In order to create an object of MailServer class, it is necessary to right click on the MailServer class and then click on new MailServer(); and then click on “ok� button.
A rectangular box will appear on BlueJ indicating that it is an object.
Similarly, an object of another class named MailClient can be created.
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
- The Cat and Dog class below implement the Animal interface. All animals have names, but only dogs do tricks. Implement the describe method, using the instanceof operator to test whether the given animal is a dog. If so, return the name, a space, and the trick that the dog can do, such as "Helmut barks at the moon". If it is any other kind of animal, return the name, a space, and "has no tricks". public class Animals{ /** Describes the given animal. @param pet an animal @return a string with the animal's name, a space, and either the trick that the animal knows (if it is a dog) or a string "has no tricks" */ public static String describe(Animal pet) { // TODO: Complete this method } // This method is used to check your work public static String check(String name, String trick) { Animal pet; if (trick == null) pet = new Cat(name); else pet = new Dog(name, trick); return describe(pet); }arrow_forwardPlease write an email class using OOP concept to send an email with "Information Technology" for the subject and "Computers" as the body. Use the getpass library to hide password. Instantiate an object and call it.arrow_forwardalso need help Write a second constructor that takes a String array of pages as input and sets the String array instance variable equal to the input. Continue to default the page number to zero. Part 2: Write a getter and a setter method for the current page number variable. The setter should check to make sure that the input is a valid page number and only update the variable if the new value is valid. Part 3: Write a getCurrentPage method that returns the String of the current page indexed by current_page. public class Ebook{ private String[] pages; private int current_page; //constructor public Ebook() { this.pages = {"See Spot.", "See Spot run.", "Run, Spot, run."}; this.current_page = 0; }}arrow_forward
- Write a mock Armor class. You will only need the protect() method. Paste it into the space below.arrow_forwardWrite a Rectangle class to represent rectangles, with two data fields (width, height) and four methods (input data, display data, calculate and return area, calculate and return perimeter). Write another class to test all methods of the Rectangle class.arrow_forwardWrite a method that takes two string parameters, and tells whether the first is a substring of the second. You can't use framework methods that do this for you, such as indexOf(). In other words, you have to write the loops yourself. But, you can use the primitive methods such as charAt(). Also analyze the program's performance and state the big-O complexity of your method. Provide a screenshot of the code working.arrow_forward
- Create a class MapTester (either in your current project or in a new project). In it, use a HashMap to implement a contacts list similar to the one in the example above. (Remember that you must import java.util.HashMap.) In this class, implement two methods: public void enterNumber(String name, String number) and public String lookupNumber(String name) The methods should use the put and get methods of the HashMap class to implement their functionality.arrow_forwardthe answer dose not include the main method. Write a main method inside the LibraryManagementSystem class, create a menu system that allows the Librarian input commands to interact with the system. Below is the menu system that students should aim to recreate. Give an appropriate message after each action to notify the Librarian if an action was successful. Make use of the toString() to print the Book objects.arrow_forwardComplete MyProgram such that you can test all conditions In the Theater constructor you need to instantiate each seat object based upon the information passed to the constructor, making sure they are available. In the reassign method, make sure the from and to seat assignments are within range and return false if not. There is test cases included with this exercise, so when you submit your screenshot, it needs to show the test cases passed.arrow_forward
- Examine the getBalance method's header and body, and then evaluate how they stack up against those of the getPrice method. I'm confused as to the differences between the two.arrow_forwardPLEASE ENSURE TO USE THE FRAMEWORK PROVIDED IN THE IMAGES, AND THAT IT WORKS WITH THE TESTER CLASS. PLEASE DONT EDIT THE TEST CLASS. Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling either switch turns the lamp on or off. Provide methods public int getFirstSwitchState() // 0 for down, 1 for up public int getSecondSwitchState()public int getLampState() // 0 for off, 1 for onpublic void toggleFirstSwitch() public void toggleSecondSwitch()arrow_forwardPLEASE ENSURE TO USE THE FRAMEWORK PROVIDED IN THE IMAGES, AND THAT IT WORKS WITH THE TESTER CLASS. PLEASE DONT EDIT THE TEST CLASS. Simulate a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling either switch turns the lamp on or off. Provide methods public int getFirstSwitchState() // 0 for down, 1 for up public int getSecondSwitchState()public int getLampState() // 0 for off, 1 for onpublic void toggleFirstSwitch() public void toggleSecondSwitch()arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education