Question

Programming Language is Java 1. Create a class to describe a car. Include fields like: make,...

Programming Language is Java
1. Create a class to describe a car. Include fields like: make, model, year and color. Add all the accessors and mutators for these fields. Add a constructor that can initialize the fields.

2. Create a class that will enable you to handle standard mail communication with a customer. Add all accessors and mutators, as well as a constructor. Add a method named fullAddress that will return the address formatted for a standard mail. Add a method named fullName that will return the name of the customer formatted for a standard mail.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1)

public class Car {
   private String make;
   private String model;
   private int year;
   private String color;
   public Car(){
       this.make="";
       this.model="";
       this.year=0;
       this.color="";
   }
   public Car(String make,String model,int year,String color){
       this.make=make;
       this.model=model;
       this.year=year;
       this.color=color;
   }
   public String getMake() {
       return make;
   }
   public void setMake(String make) {
       this.make = make;
   }
   public String getModel() {
       return model;
   }
   public void setModel(String model) {
       this.model = model;
   }
   public int getYear() {
       return year;
   }
   public void setYear(int year) {
       this.year = year;
   }
   public String getColor() {
       return color;
   }
   public void setColor(String color) {
       this.color = color;
   }
  

}

2)

public class CustomerMail {

   private String firstName;
   private String lastName;
   private String address;
   private String zipcode;
   public CustomerMail(){
       this.firstName="";
       this.lastName="";
       this.address="";
       this.zipcode="";
   }
   public CustomerMail(String firstName,String lastName,String address,String zip){
       this.firstName=firstName;
       this.lastName=lastName;
       this.address=address;
       this.zipcode=zip;
   }
   public String getFirstName() {
       return firstName;
   }
   public void setFirstName(String firstName) {
       this.firstName = firstName;
   }
   public String getLastName() {
       return lastName;
   }
   public void setLastName(String lastName) {
       this.lastName = lastName;
   }
   public String getAddress() {
       return address;
   }
   public void setAddress(String address) {
       this.address = address;
   }
   public String getZipcode() {
       return zipcode;
   }
   public void setZipcode(String zipcode) {
       this.zipcode = zipcode;
   }
   public String fullAddress(){
       return "Name: "+this.firstName+" "+this.lastName+"\nDelivery Address:"+
               this.address+"\nZipcode: "+this.zipcode;
   }
   public String fullName(){
       return this.firstName+" "+this.lastName;
   }
}

Add a comment
Know the answer?
Add Answer to:
Programming Language is Java 1. Create a class to describe a car. Include fields like: make,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write...

    Java - Object Oriented Programming Declare a class named Customer that has two private fields? Write a set method to make sure that if age > 125 years or less than 0 then it is set to 0 (default value) What does it indicate when declaring a class's instance variables with private access modifier? What is the role of a constructor? The data part of by an object's instance variables is known as? Do all methods have to always return...

  • Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the...

    Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the type int, assessedPrice of the type double. A constructor for this class should have three arguments for initializing these fields. Add accessors and mutators for all fields except a mutator for yearBuilt, and the method toString. Create a class StreetHouse which extends House and has additional fields: streetNumber of the type int, homeowner of the type String, and two neighbors: leftNeighbor and rightNeighbor, both...

  • Programming Language: Java Write a class named ColoredRectangle that extends the Rectangle class (given below). The...

    Programming Language: Java Write a class named ColoredRectangle that extends the Rectangle class (given below). The ColoredRectangle class will have an additional private String field named Color. The ColoredRectangle class should have four constructors: a no-arg constructor; a three-arg constructor; a two-arg constructor that accepts a Rectangle object and a color; and a copy constructor. The ColoredRectangle class should have an Equals and toString methods. The ColoredRectangle class should have mutators and accessors for all three fields. public class Rectangle...

  • (JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a...

    (JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a Zoo class. Include data fields such as name of zoo, location, size, fee for the past 12 months, number of visitors recorded for the past 12 months, admission rates per visitor and annual budget. (20 points) 2. Include at least two mutators and two accessors. (15 points) 3. Include one default constructor and one more constructor. (15 points) 4. Write separate instance methods that...

  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • With Java Language: In this assignment, you are to create a class named Payroll. In the...

    With Java Language: In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) .İd: String (5 pts) hours: int (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an...

  • Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you...

    Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you are expected to implement in your Shape class; - A private String color that specifies the color of the shape - A private boolean filled that specifies whether the shape is filled - A private date (java.util.date) field dateCreated that specifies the date the shape was created Your Shape class will provide the following constructors; - A two-arg constructor that creates a shape with...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method...

    Programming 5_1: Create a Java class named <YourName>5_1 In this class create a main method, but for now leave it empty. Then write a Java method getAverage which takes an array of integers as it’s argument. The method calculate the average of all the elements in the array, and returns that average. The method should work for an array of integers of any length greater than or equal to one. The method signature is shown below: public static double getAverage(...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT