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...
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 = ""; ...
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() { ...
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 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...
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...
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...
4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...
I have to create two classes one class that accepts an object, stores the object in an array. I have another that has a constructor that creates an object. Here is my first class named "ShoppingList": import java.util.*; public class ShoppingList { private ShoppingItem [] list; private int amtItems = 0; public ShoppingList() { list=new ShoppingItem[8]; } public void add(ShoppingItem item) { if(amtItems<8) { list[amtItems] = ShoppingItem(item);...