Question

In: Computer Science

Each apple has a unique ID . In the format of AppleID. Where D is the...

Each apple has a unique ID . In the format of AppleID.

Where D is the serial number, starting from 1.

That is the first apple object gets Apple 1 and the second Apple 2

public class Apple{

String AppleID;

// create an apple with appleD of form apple-XX

public Apple(){

}

}

Add fields if you think you need one. Write none if you dont

Complete the constructor so that the 1st apple gets Apple ID apple-1, the second apple gets apple-2.

Solutions

Expert Solution

HI,

Created a complete program where you can create number of apples id and form by class constructor.

Run below program and you will get 5 form of apples.

public class Apple{

private String AppleID; //Apple id
private String AppleType; // representing apples varieties

// create an apple with appleD of form apple-XX
//apple contructor
public Apple(String id, String type){
        this.AppleID = id;
        this.AppleType = type;

}
// to string method to print apple id and apple name
public String toString() {

        return AppleID+"                  "+AppleType+"\n";

    }

//driver method
        public static void main(String[] args) 
        {
                Apple apple1 = new Apple("apple-1", "Ambri Apple");  // create a apple form based on apple id by class contructor
                Apple apple2 = new Apple("apple-2", "McIntosh apple");
                Apple apple3 = new Apple("apple-3", "Granny Smith");
                Apple apple4 = new Apple("apple-4", "Golden Delicious");
                Apple apple5 = new Apple("apple-5", "Honeycrisp");
                System.out.println("\n");
                System.out.println("AppleID                  Apple form\n");
                System.out.println(apple1);// displaying output
                System.out.println(apple2);
                System.out.println(apple3);
                System.out.println(apple4);
                System.out.println(apple5);


        }

}

Thanks


Related Solutions

Data Description: Response ID:             A unique identifier for each respondent in the survey Liking:               &nbsp
Data Description: Response ID:             A unique identifier for each respondent in the survey Liking:                       Respondent’s overall liking of their XYZ car (1 = least liked, 5 = most liked) Rating:                       Respondent’s rating of their XYZ car’s fuel efficiency (1 = poor, 5 = excellent) Importance:               Importance of fuel efficiency when purchasing an automobile (1 = extremely unimportant, 5 = extremely important) 1.4 Suppose instead that the questionnaire captured fuel efficiency ratings through the following item: How would you rate...
Define a table with the following properties that represent an election. Create a unique id for...
Define a table with the following properties that represent an election. Create a unique id for the table. Create a field or fields representing an election's description. Create a field or fields representing an election's date. Create a field or fields representing an election's status (active or inactive)
Solve each of the following ODEs. If initial conditions are given, give the unique solution. d)...
Solve each of the following ODEs. If initial conditions are given, give the unique solution. d) y''' − 5y'' + 2y' + 8y = 0, y(0) = 2, y'(0) = −1, y''(0) = −5 e) y''' + 9y'' + 27y' + 27y = 0, y(0) = 2, y'(0) = 0, y''(0) = 3 a) x^2y'' + xy' + 4y = 0, x > 0 b) x^2y'' − 6y = 0, x > 0, y(1) = y'(1) = 5 c) x^2y''...
Given an experimental design with four factors A, B, C and D where each factor has...
Given an experimental design with four factors A, B, C and D where each factor has two levels. Derive the formula for effect estimation of main effect of ?, interaction effect of ??, ??? and ????. (please use (1),a,b,c,d,ab,ac,ad,bc,bd,cd,abc,abd,acd,bcd,abcd to represent the response)
Reconsider your student ID in a binary format (as explained in the previous question) as the...
Reconsider your student ID in a binary format (as explained in the previous question) as the dataword. 2.1) Find the codeword corresponding to this dataword using the CRC error detection technique, and the divisor polynomial g(x) = x3+x2+1. Do Binary division with 0s and 1s. 2.2) Compute now the codeword corresponding to this dataword assuming that the divisor polynomial that is used is f(x) = x5+1. Do Polynomial division. 2.3) Assume that an error corrupted the first two bits of...
Reconsider your student ID in a binary format (as explained in the previous question) as the...
Reconsider your student ID in a binary format (as explained in the previous question) as the dataword. 2.1) Find the codeword corresponding to this dataword using the CRC error detection technique, and the divisor polynomial g(x) = x3 +x2 +1. Do Binary division with 0s and 1s. 2.2) Compute now the codeword corresponding to this dataword assuming that the divisor polynomial that is used is f(x) = x5+1. Do Polynomial division. 2.3) Assume that an error corrupted the first two...
Make quicksort functions to sort this class, first by ID then by athleteEvaluation athleteID: an unique...
Make quicksort functions to sort this class, first by ID then by athleteEvaluation athleteID: an unique identifier for the athlete athletePosition: an abbreviation of the expected player’s position on the team. We will use an enumerated data type to store the position within our BUAthlete class. A definition of the enumerated data type is provided below. Don't forget that enumerated data types are actually stored as integers. enum Position {OL, QB, RB, WR, TE, DL, DE, LB, CB, S, K};...
Apple company opportunities with intext cation please and references (APA FORMAT)
Apple company opportunities with intext cation please and references (APA FORMAT)
Apple Inc., has is holding a tremendous amount of cash. Most is held overseas where the...
Apple Inc., has is holding a tremendous amount of cash. Most is held overseas where the profit was made. In the past several years they started paying dividends by borrowing by issuing bonds. The have similarly repurchased large amounts of shares. Do you think this is in the best interests of shareholders? What do you think Apple should do with their cash position? Why do you think they are holding onto so much cash?
Theory Questions 1. The Kyrgios Database Group has about 120 employees. Each employee has an ID,...
Theory Questions 1. The Kyrgios Database Group has about 120 employees. Each employee has an ID, a firstname and a surname. Each employee belongs to a department. The organisation has around 6 departments. Each department has a department code and a departmentname. • Create an ERD solution based on the above narrative. ERD Diagram Question 2. The Tomic Primary School wishes to democratically choose which animal will become the school mascot. The list of alternatives includes Kangaroo, Koala, Tiger, Elephant,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT