write a parent class that describes a parcel (like a package, as shown below) and a child class that describes an overnight parcel. Use the provided Address class.
A parcel is described by:
An overnight parcel is described by id, weight, destination address and also:
public class Address {
private String name, street, city, state, zip;
public Address(String name, String street, String city, String state, String zip) {
this.name = name;
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
@Override
public String toString() {
return name + "\n" + street + "\n" + city + ", " + state + " " + zip;
}
}
Classes in JAVA
class Address {
private String name, street, city, state, zip;
public Address(String name, String street, String city, String state, String zip) {
this.name = name;
this.street = street;
this.city = city;
this.state = state;
this.zip = zip;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
@Override
public String toString() {
return name + "\n" + street + "\n" + city + ", " + state + " " + zip;
}
}
class Parcel{
String id;
double weight;
Address address;
Parcel(String id, double weight, Address address){
this.address=address;
this.id=id;
this.weight=weight;
}
String getID(){
return id;
}
String getAddress(){
return address.toString();
}
double getWeight(){
return weight;
}
void setWeight(double weight){
this.weight=weight;
}
void setAddress(Address address){
this.address=address;
}
void setID(String id){
this.id=id;
}
}
class OvernightParcel extends Parcel{
boolean signature;
OvernightParcel(String id, double weight, Address address, boolean signature){
super(id, weight, address);
this.signature=signature;
}
boolean getSignature(){
return this.signature;
}
void setSignature(boolean s){
signature=s;
}
}
write a parent class that describes a parcel (like a package, as shown below) and a...
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 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...
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...
For this problem, we are going to revisit the Online Company exercise from lesson 3. In lesson 3, we created 3 classes, a superclass Company, a subclass OnlineCompany and a runner class CompanyTester. You can take your solutions from lesson 3 for the Company and OnlineCompany, but we are going to redesign the CompanyTester in this exercise. Your task is to create a loop that will allow users to enter companies that will then get stored in an ArrayList. You...
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...
Java Do 72a, 72b, 72c, 72d. Code & output required. public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...
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...
How to solve this problem? Consider the following class : public class Store Public final double SALES TAX_RATE = 0.063B private String name; public Store(String newName) setName ( newName); public String getName () { return name; public void setName (String newName) { name = newName; public String toString() return "name: “ + name; Write a class encapsulating a web store, which inherits from Store. A web store has the following additional attributes: an Internet Address and the programming language in...
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() { ...
ble and instance variable, and then use clas 4. Please discuss the difference between class variable and instant variable to complete the following code for the count of number of stud public class Student _//q1: fill this line to create a class variable num. public Student 1/ 22: fill this line to increase num. public static int getNum() return num; public static void main(String[] args) { Student stl=new Student O; Student st2-new Student ; Student st3-new Student ; //q3: fill...