Concept explainers
I need this to work in BlueJ
Go off this code:
public abstract class Employee
{
private String firstName;
private String lastName;
private String SSN;
double salary;
public Employee( String first, String last, String ssn )
{
firstName = first;
lastName = last;
SSN = ssn;
}
public void setfirstName( String first )
{
firstName = first; // should validate
}
public String getfirstName()
{
return firstName;
}
public void setlastName( String last )
{
lastName = last; // should validate
}
public String getlastName()
{
return lastName;
}
public void setSSN( String ssn )
{
this.SSN = ssn;
}
public String getSSN()
{
return SSN;
}
@Override
public String toString()
{
return String.format( "%-12s%-12s%-12s", getfirstName(), getlastName(), getSSN() );
}
public abstract double earnings();
}
Step by stepSolved in 4 steps with 2 images
- Consider the following code: class Player { private: string ID; string name; public: Player(string n, string s) { name = n; setID(s); } string getName() const { return name; } string getID() const { return ID; } void setID(string s) { ID = s; } }; class BasketballPlayer : public Player { private: int fieldgoals; int attempts; public: BasketballPlayer(string n, string i, int fg, int a) : Player(n, i) { fieldgoals = fg; attempts = a; } // line 1 void printStats() const { cout << " Pct: " << (double) fieldgoals / attempts << endl; } }; int main() { Player golfer("Tiger Woods", "123456789"); BasketballPlayer pointGuard("Stephen Curry", "567890123", 2585, 5523); } Describe the code : Player(n, i) at the end of the BasketballPlayer constructor. a. calls the Player constructor with parameters n, i c. derives Player from BasketballPlayer d. derives BasketballPlayer from Player e. calls the Player…arrow_forwardclass smart { public: void print() const; void set(int, int); int sum(); smart(); smart(int, int); private: int x; int y; int secret(); }; class superSmart: public smart { public: void print() const; void set(int, int, int); int manipulate(); superSmart(); superSmart(int, int, int); private: int z; }; Now answer the following questions: a. Which private members, if any, of smart are public members of superSmart? b. Which members, functions, and/or data of the class smart are directly accessible in class superSmart?arrow_forwardFind the error(s) in the following class definition: public class TestClass private int value1; private int value2; public void TestClass(int num1, int num2) { value1= num1; value2 = num2; }arrow_forward
- Incorrect Question 4 Consider public class Species { } // fields private String name; private int population; private double growthRate; // constructor public Species () { } name = "No Name Yet"; population = 0; growthRate = 33.3; Which of the following is the best setter method for the population instance variable? public boolean setPopulation(int newPopulation) { } if (newPopulation>= 0) { } population = newPopulation; return false; } return true; public public void setPopulation (int newPopulation) if (newPopulation>= 0) { } population newPopulation; public void setPopulation (int newPopulation) { population } = newPopulation;arrow_forwardpublic class Cat extends Pet { private String breed; public void setBreed(String userBreed) { breed = userBreed; } public String getBreed() { return breed; }} public class Pet { protected String name; protected int age; public void setName(String userName) { name = userName; } public String getName() { return name; } public void setAge(int userAge) { age = userAge; } public int getAge() { return age; } public void printInfo() { System.out.println("Pet Information: "); System.out.println(" Name: " + name); System.out.println(" Age: " + age); } } import java.util.Scanner; public class PetInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); // create a generic Pet and a Cat Pet myPet = new Pet(); Cat myCat = new Cat(); // declare variables for pet and cat info String petName, catName, catBreed; int petAge,…arrow_forwardpublic class Cylinder { public void smoothen() { } } } public abstract class Vessel implements Steerable { private Engine e; } System.out.println("Smoothening.."); public Engine getEngine() { return e; } public void setEngine (Engine e) { this.e = e; } public abstract void turnOn(); public class Engine { private Cylinder [] y; private int cyls = 1; static final int maxCylinders = 12; public void addCylinder (Cylinder y) { if (cylsarrow_forwardFinish the constructor for the KickBall class. public class Ball { public double diameter; public Ball(double diam) { diameter = diam; public class KickBall extends Ball private Color ballColor; public KickBall(double diam, Color ballColor) {arrow_forwardpublic abstract class Shape { public Shape() { } public abstract double area() ; public String who() { return "Shape" ; } } public class Circle extends Shape { private int radius ; public Circle( int r ) { radius = r ; } @Override public double area() { return Math.PI * radius * radius ; } } public class Square extends Shape { private int _sideLength ; public Square( int sideLength ) { /* TODO question 45 */ } @Override public double area() { return _sideLength * _sideLength ; } } Implement the Square constructor, and make sure it throws an exception when the input parameter is not a valid length. The input parameter must be positive to be considered valid.arrow_forwardarrow_back_iosarrow_forward_ios
- 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