Question

Create a field with the boolean value of goodBoi. In the constructor, set your good boi...

  1. Create a field with the boolean value of goodBoi.
  2. In the constructor, set your good boi to being false, as all dogs has deserve being called a good boiii.
  3. Make a method makeGoodBoi, which sets the good boi value to being true.
  4. Make a method isGoodBoi which returns the value the good boi field (hint: it returns a boolean value).
  5. Now we need a method called whosAGoodBoi. If the doggo is indeed a good boi, then print: "[doggo] is such a goood boii". If they are not yet a good boi, then print: "[doggo] is not a good boi :(". Doggo is the name of the doggo (like in the last exercise).

    Hey I have this ^ assignment and I am stuck at 5. but I don't know if it is something I have done wrong earlier.
    I will just submit my code below and hopefully someone can tell me what I am doing wrong :

    public class Doggo {

    // field

    String name;

    Boolean goodBoi;

    //constructor

    public Doggo(String name) {

    this.name = name;

    this.goodBoi = false;

    }

    //getName method

    public String getName()

    {

    return name;

    }

    // makeBark method

    public void makeBark ()

    {

    System.out.println(this.name + " " + "said: Woof woof");

    }

    // makeGoodBoi method

    public void makeGoodboi()

    {

    this.goodBoi = true;

    }

    // is GoodBoi

    public static boolean isGoodBoi()

    {

    return false;

    }

    // whosAGoodBoi

    public void whosAGoodBoi(Doggo mira) {

    if (Doggo.isGoodBoi()); {

    System.out.println(mira.getName() + "" + "is such a good boii");

    }

    else {

    System.out.println(mira.getName()+ "" + "is not a good boi :(");

    }

    }

    }

    public class Main {

    public static void main(String[] args) {

    Doggo mira = new Doggo("mira");

    mira.makeBark();

    }

    }

Homework Answers

Answer #1

class Doggo {

// field
  
String name;
  
Boolean goodBoi;
  
//constructor
  
public Doggo(String name) {
  
this.name = name;
  
this.goodBoi = false;
  
}
  
//getName method
  
public String getName() {
  
return name;
  
}
  
// makeBark method
  
public void makeBark () {
  
System.out.println(this.name + " " + "said: Woof woof");
  
}
  
// makeGoodBoi method
  
public void makeGoodboi(){
this.goodBoi = true;
}
  
// is GoodBoi
  
public boolean isGoodBoi() {
return goodBoi;
}
  
// whosAGoodBoi
  
public void whosAGoodBoi(Doggo mira) {

if (mira.isGoodBoi()) {
  
System.out.println(mira.getName() + "" + "is such a good boii");
  
}
  
else {
  
System.out.println(mira.getName()+ "" + "is not a good boi :(");
  
}
  
}
  
}

public class Main {

public static void main(String[] args) {
  
Doggo mira = new Doggo("mira");
  
mira.makeGoodboi(); // here I am making good boi. so the status is true
mira.whosAGoodBoi(mira);
  
}

}

Know the answer?
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
Similar Questions
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__...
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__ salary; // constructor (2) ________________________________________ // method public (3) __String____ getName( ){ return name; } public float getSalary( ){ return Salary; } public (4) ________ compare( (5) _________________ { (6) ____________________________________ } }// class Employee public class EmployeeUI{ public static void main(String[ ] args){ Employee e1 = new Employee(“William”); Employee e2 = new Employee(“Rchard”); if(Employee.compare(e1, e2)) System.out.println(“same employee”); else System.out.println(“different employee”); } }//class EmployeeUI
How do I make this: public class Country {     private String name;     private double area;     private...
How do I make this: public class Country {     private String name;     private double area;     private int population;     public Country(String name, double area, int population) {         this.name = name;         this.area = area;         this.population = population;     }     public double getPopulationDensity() {         return population / area;     }     public String getName() {         return name;     }     public void setName(String name) {         this.name = name;     }     public double getArea() {         return area;     }     public void setArea(double area) {         this.area = area;     }     public int getPopulation()...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with...
Java Program Implement a class called AnimalTrainer. Include the following data types in your class with the default values denoted by dataType name : defaultValue - String animal : empty string - int lapsRan : 0 - boolean resting : false - boolean eating : false - double energy : 100.00 For the animal property implement both getter/setter methods. For all other properties implement ONLY a getter method Now implement the following constructors: 1. Constructor 1 – accepts a String...
Java: ModifyStudentList.javato use anArrayListinstead of an array In StudentList.java, create two new public methods: The addStudent...
Java: ModifyStudentList.javato use anArrayListinstead of an array In StudentList.java, create two new public methods: The addStudent method should have one parameter of type Student and should add the given Student to the StudentList. The removeStudent method should have one parameter of type String. The String is the email of the student to be removed from the StudentList. In Assign5Test.java do the following: Create a new StudentList containing 3 students. Print the info of all the Students in the StudentList using...
Which method is correct to access the value of count? public class Person { private String...
Which method is correct to access the value of count? public class Person { private String name; private int age; private static int count = 0; } A. private int getCount() {return (static)count;} B. public static int getCount() {return count;} C. public int getCount() {return static count;} D. private static int getCount() {return count;} How can you print the value of count? public class Person { private String name; private int age; private static int count=0; public Person(String a, int...
Determine how all of your classes are related, and create a complete UML class diagram representing...
Determine how all of your classes are related, and create a complete UML class diagram representing your class structure. Don't forget to include the appropriate relationships between the classes. GameDriver import java.util.Scanner; public class GameDriver { Scanner in = new Scanner(System.in); public static void main(String[] args) { Move move1 = new Move("Vine Whip", "Grass", 45, 1.0f); Move move2 = new Move("Tackle", "Normal", 50, 1.0f); Move move3 = new Move("Take Down", "Normal", 90, 0.85f); Move move4 = new Move("Razor Leaf", "Grass",...
ex3 Write a method public static boolean isPalindrome(String input) that uses one or more stacks to...
ex3 Write a method public static boolean isPalindrome(String input) that uses one or more stacks to determine if a given string is a palindrome. [A palindrome is a string that reads the same forwards and backwards, for example ‘racecar’, ‘civic’]. Make sure that your method works correctly for special cases, if any. What is the big-O complexity of your method in terms of the list size n. Supplementary Exercise for Programming (Coding) [Stacks] Download and unpack (unzip) the file Stacks.rar....
Class VacationPackage java.lang.Object triptypes.VacationPackage Constructor Summary Constructors Constructor and Description VacationPackage(java.lang.String name, int numDays) Initializes a...
Class VacationPackage java.lang.Object triptypes.VacationPackage Constructor Summary Constructors Constructor and Description VacationPackage(java.lang.String name, int numDays) Initializes a VacationPackage with provided values. Method Summary All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description boolean equals(java.lang.Object other) Provides a logical equality comparison for VacationPackages and any other object type. double getAmountDue() This method provides the remaining amount due to the travel agent for this trip less any deposit made upfront. abstract double getDepositAmount() This method provides the required...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new...
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // Read the input string String input = sc.nextLine(); BalancedParentheses bp = new BalancedParentheses(); // Print whether the string has balanced parentheses System.out.println(bp.hasBalancedParentheses(input)); } } class BalancedParentheses { public boolean hasBalancedParentheses(String input) { // Remove this and implement code throw new UnsupportedOperationException(); } }
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT