How to create a constructor that uses parameters from different classes?
I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer.
I have to create an object like the example below.......
PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams",
"Los Angeles, CA", "3235331234", 933, true, 400);
System.out.println(preferredcustomer1.toString() + "\n");
public class Person {
private String name;
private String address;
private long phoneNum;
public Person(String name, String address, long phoneNum) {
this.name = name;
this.address = address;
this.phoneNum = phoneNum;
}
public Person(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public long getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(long phoneNum) {
this.phoneNum = phoneNum;
}
}
public class Customer extends Person {
int CustomerNum;
boolean mailingList;
public Customer(int customerNum, boolean mailingList) {
CustomerNum = customerNum;
this.mailingList = mailingList;
}
public Customer(){
}
public int getCustomerNum() {
return CustomerNum;
}
public void setCustomerNum(int customerNum) {
CustomerNum = customerNum;
}
public boolean isMailingList() {
return mailingList;
}
public void setMailingList(boolean mailingList) {
this.mailingList = mailingList;
}
}
public class PrefferedCustomer extends Customer{
private int amountOfPurchase;
private double discount;
public PrefferedCustomer(Person name,Customer ,int amountOfPurchase) {
this.amountOfPurchase = amountOfPurchase;
this.discount = discount;
}
public int getAmountOfPurchase() {
return amountOfPurchase;
}
public void setAmountOfPurchase(int amountOfPurchase) {
this.amountOfPurchase = amountOfPurchase;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
}
public class Person {
private String name;
private String address;
private long phoneNum;
public Person(String name, String address, long phoneNum) {
this.name = name;
this.address = address;
this.phoneNum = phoneNum;
}
public Person(){
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public long getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(long phoneNum) {
this.phoneNum = phoneNum;
}
}
==============================
public class Customer extends Person {
int CustomerNum;
boolean mailingList;
public Customer(int customerNum, boolean mailingList) {
CustomerNum = customerNum;
this.mailingList = mailingList;
}
public Customer(){
}
public Customer(String name, String address, long phoneNum, int customerNum, boolean mailingList) {
super(name, address, phoneNum);
CustomerNum = customerNum;
this.mailingList = mailingList;
}
public int getCustomerNum() {
return CustomerNum;
}
public void setCustomerNum(int customerNum) {
CustomerNum = customerNum;
}
public boolean isMailingList() {
return mailingList;
}
public void setMailingList(boolean mailingList) {
this.mailingList = mailingList;
}
}
==============================
public class PrefferedCustomer extends Customer{
private int amountOfPurchase;
private double discount;
public PrefferedCustomer(Person name,int amountOfPurchase) {
this.amountOfPurchase = amountOfPurchase;
this.discount = discount;
}
public PrefferedCustomer(String name, String address, long phoneNum, int customerNum, boolean mailingList, int amountOfPurchase) {
super(name, address, phoneNum, customerNum, mailingList);
this.amountOfPurchase = amountOfPurchase;
}
public int getAmountOfPurchase() {
return amountOfPurchase;
}
public void setAmountOfPurchase(int amountOfPurchase) {
this.amountOfPurchase = amountOfPurchase;
}
public double getDiscount() {
return discount;
}
public void setDiscount(double discount) {
this.discount = discount;
}
}
=====================================

How to create a constructor that uses parameters from different classes? I have to create a...
I have a java class that i need to rewrite in python. this is what i have so far: class Publisher: __publisherName='' __publisherAddress='' def __init__(self,publisherName,publisherAddress): self.__publisherName=publisherName self.__publisherAddress=publisherAddress def getName(self): return self.__publisherName def setName(self,publisherName): self.__publisherName=publisherName def getAddress(self): return self.__publisherAddress def setAddress(self,publisherAddress): self.__publisherAddress=publisherAddress def toString(self): and here is the Java class that i need in python: public class Publisher { //Todo: Publisher has a name and an address. private String name; private String address; public Publisher(String...
Can someone tell me how to create a test for the following Hotel classes that test all of the methods? public class Bed { private String type; private static final String[] TYPES ={"Single", "Double", "King Size"}; public Bed(String type) { this.type = type; } public boolean isSingle() { return type.equals(TYPES[0]); } public boolean isDouble() { return type.equals(TYPES[1]); } public boolean isKingSize() { return type.equals(TYPES[2]); } } public class Guest { private String name; public Guest (String name) { this.name...
Assignment (to be done in Java):
Person Class:
public class Person extends Passenger{
private int numOffspring;
public Person() {
this.numOffspring = 0;
}
public Person (int numOffspring) {
this.numOffspring = numOffspring;
}
public Person(String name, int birthYear, double weight, double
height, char gender, int numCarryOn, int numOffspring)
{
super(name, birthYear, weight, height, gender,
numCarryOn);
if(numOffspring < 0) {
this.numOffspring = 0;
}
this.numOffspring = numOffspring;
}
public int getNumOffspring() {
...
write comments // on this program please //Inside package bloodDonation //BloodDonor.java class package bloodDonation; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Scanner; public class BloodDonor { long idNumber, cardNumber; String name, bloodGroup, homePhone, mobilePhone, address, lastDateOfDonation; SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); public BloodDonor(){ this.idNumber = 0; this.cardNumber = 0; this.name = ""; this.bloodGroup = ""; this.homePhone = ""; this.mobilePhone = ""; this.address = ""; ...
I have done a decent amount of coding... but I need you to help me understand what I do not. Please, post comments so that I can learn from you. Here are the instructions for this portion of the project: Create the Monkey class, using the specification document as a guide. The Monkey class must do the following: Inherit from the RescueAnimal class Implement all attributes with appropriate data structures Include accessors and mutators for all implemented attributes Here is...
JAVA How to add array to develop a contact list application for the person class objects developed in this code? The application will include functionality to add, remove, sort and search the contact list. You should also include a method to output the contents of a contact searched for, and also to output the entire list. The code: package BankProg; public class personal { private String facebook; public personal() { } public personal(String facebook) { this.facebook...
I need help converting the following two classes into one sql table package Practice.model; import java.util.ArrayList; import java.util.List; import Practice.model.Comment; public class Students { private Integer id; private String name; private String specialties; private String presentation; List<Comment> comment; public Students() {} public Students(Integer id,String name, String specialties, String presentation) { this.id= id; this.name = name; this.specialties = specialties; this.presentation = presentation; this.comment = new ArrayList<Commment>(); } public Students(Integer id,String name, String specialties, String presentation, List<Comment> comment) { this.id= id; this.name...
public enum Rating { GENERAL(0), PARENTALGUIDANCE(1), MATURE(2); private int minAge; private Rating(int i) { minAge = i; } public int getMinAge() { return minAge; } public void setMinAge(int age) { minAge = age; } public String toString() { switch(this) { case GENERAL: return "G"; case PARENTALGUIDANCE: return "P"; case MATURE: return...
Hi, I am writing Java code and I am having a trouble working it out. The instructions can be found below, and the code. Thanks. Instructions Here are the methods needed for CIS425_Student: Constructor: public CIS425_Student( String id, String name, int num_exams ) Create an int array exams[num_exams] which will hold all exam grades for a student Save num_exams for later error checking public boolean addGrade( int exam, int grade ) Save a grade in the exams[ ] array at...
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...