UserInfo. java
-----------------------
public class UserInfo {
private String firstName;
private String lastName;
private String location= "Not specified";
private int age=0;
private static final int OFFLINE =0, ONLINE=1;
private int status = OFFLINE;
public UserInfo(String firstNameIn, String
lastNameIn) {
super();
firstName = firstNameIn;
lastName = lastNameIn;
}
@Override
public String toString() {
String output= " firstName : " +
firstName + "\n lastName : " + lastName + "\n location : " +
location + "\n age : " + age
+ "\n status : " + status;
if(status==OFFLINE){
output+=
"offline";
}
else
{
output+=
"online";
}
return output;
}
public boolean setAge(int ageIn){
boolean isSet = false;
if(ageIn>0){
age=ageIn;
isSet=true;
}
return isSet;
}
public int getAge(){
return age;
}
public String getLocation(){
return location;
}
public void logOff(){
status=OFFLINE;
}
public void logOn(){
status=ONLINE;
}
public void setLocation(String location) {
this.location = location;
}
public static void main(String[] args) {
UserInfo u = new UserInfo("Jane",
"Lane");
System.out.println(u);
u.setAge(23);
u.setLocation("Auburn");
u.logOn();
System.out.println(u);
}
}
UserDriveInfo.java
----------------------
public class UserInfoDriver {
public static void main(String[] args) {
// TODO Auto-generated method
stub
UserInfo user1 = new
UserInfo("Fat", "Doe");
System.out.println("\n"+
user1);
user1.setLocation("Aur=burn");
user1.setAge(19);
user1.logOn();
System.out.println("\n"+
user1);
UserInfo user2 = new
UserInfo("Sam", "Jones");
System.out.println("\n"+
user2);
user2.setLocation("Aurburn");
user2.setAge(19);
user2.logOn();
System.out.println("\n"+
user2);
}
}
The above programs are created as your instructions. I hope it helpful
Thank you.
Note: You can create UML diagrams in Eclipse IDE easily with these programs.
Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class...
The current code I have is the following: package uml; public class uml { public static void main(String[] args) { // TODO Auto-generated method stub } } class Account { private String accountID; public Account(String accountID) { this.accountID = accountID; } public String getAccountID() { return accountID; } public void setAccountID(String accountID) { this.accountID = accountID; } @Override public String toString() { return "Account [accountID=" + accountID + "]"; } } class SuppliesAccount extends Account { private...
I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...
Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program: Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...
Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...
Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...
In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...
Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...
Implement the classes in the following class diagram. The Book class implements the Comparable interface. Use implements Comparable<Book> in the class definition. Now, all book objects are instances of the java.lang.Comparable interface. Write a test program that creates an array of ten books. 1. Use Arrays.sort( Book[]l books) from the java.util package to sort the array. The order of objects in the array is determined using compareTo...) method. 2. Write a method that returns the most expensive book in the...
Please follow the instructions carefully. Thank you! For the second activity, I outputted the superhero class below. SUPERHERO CLASS public class Superhero{ private String alias; private String superpower; private int health; public Superhero(){ alias= "unkown"; superpower= "unknown"; health= 50; //Realized I did not use default constructor while going through instructions of lab } public Superhero(String alias1, String superpower1,int health1 ){ alias=alias1; superpower=superpower1; if(health1>=0 && health1<=50) health= health1; else if(health1<0||health1>50) health=25; } public void setalias(String alias1){ alias=alias1; } public void setsuperpower(String...