Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Dummy Assignment

1 answer below »
Answered 13 days After Feb 10, 2021

Solution

Kshitij answered on Feb 24 2021
151 Votes
Ques no 1:-
Person Interface:--
package feb22_21;
public interface Person {

create 3 attribute in the Person Interface
String firstName=null;
String lastName=null;
String Color=null;

create a method toString which has no method
public String toString();

create a new class Height
class Height{

having a attribute height of integer type
public int height;

Constructor of Height class
public Height(int height) {
this.height = height;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
@Ove
ide
public String toString() {
return "Height :- "+this.height;
}
}

Create a new Class 'FootballPlayer' which is implements from Person
class

Ove
ide the all methods of the Person class
class FootballPlayer implements Person {
public String name;
public Height height;
public FootballPlayer(Height height) {
this.height = height;
this.name="Messi";
}
public FootballPlayer(String name, Height height) {
this.name = name;
this.height = height;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Height getHeight() {
return height;
}
public void setHeight(Height height) {
this.height = height;
}

Ove
ide the toString method from the Person class
@Ove
ide
public String toString() {
return this.name+" "+this.height;
}
}

create a OffensiveLine having a attribute footballType of type
FootballPlayer type
class OffensiveLine{
public FootballPlayer footballPlayer;

constructor
public OffensiveLine(FootballPlayer footballPlayer) {
this.footballPlayer = footballPlayer;
}
public FootballPlayer getFootballPlayer() {
return footballPlayer;
}
public void setFootballPlayer(FootballPlayer footballPlayer) {
this.footballPlayer = footballPlayer;
}
@Ove
ide
public String toString() {
return "Name :- "+this.footballPlayer;
}
}
}
Execution class:--
* Created by IntelliJ IDEA.
* Author: Kshitij Varshney (kshitijvarshne1)
* Date: 22-Feb-21
* Time: 12:29 AM
* File: Execution.java
*
package feb22_21;
import feb22_21.Person.FootballPlayer;
import feb22_21.Person.Height;
import feb22_21.Person.OffensiveLine;
public class Execution {
public static void main(String[] args) {
FootballPlayer footballPlayer= new FootballPlayer(new Height(5));
System.out.println(footballPlayer);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here