Question

In: Computer Science

1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class...

1. PHP OOP

Create a complete PHP enabled website that defines and uses a PineApple class in PHP. The class has following members.

Properties

$color: string type

$taste: string type

$weight: number type

Standard constructor, with 3 parameters

Member functions

eat(): no return, no parameter, print a short paragraph in English to describe

how to eat a pineapple.

grow(): no return, no parameter, print a short paragraph in English to describe how to grow a pineapple plant.

display(): no return, no parameter, print the name and current value of every property of this class.

In the primary PHP script, create two objects from the PineApple class. Then call every member function form each object in an appropriate manner.

2. JavaScript OOP

Write a complete webpage with embedded JavaScript code that defines a bunny object that is made of following properties and methods.

Property color: string type

Property earLength: number type

Property furType: string type

Method toPrint(): print out the name and value of every property of this current object

Method run(): print out the procedure that describes how this bunny swims.

In details, do the following

Create a bunny object using object literal.

Define the constructor function of bunny and create another bunny object using this constructor and the new keyword.

Read three property values from the keyboard with proper prompt for every object created above.

For each object, call its every method.

Solutions

Expert Solution

Please try to divide multiple questions to seperate individual questions. Here is the code for the first one. PHP:
------

<?php

class PineApple{
   var $color;
   var $taste;
   var $weight;

   function __construct($c, $t, $w){
       $this->color = $c;
       $this->taste = $t;
       $this->weight = $w;
   }

   function eat(){
       echo "<br><br>Cut PineApple into pieces using a knife or by hand if you like. Remember to remove outer shell before otherwise it case cause some serious damage to stomache. Then just eat it bro.";
   }

   function grow(){
       echo "<br><br>Find PineApple seeds somewhere lying around, I don't know man where you can find them just buy it on amazon. Then get some water, some soil, some sunlight and mix them up together. Bamm! you got PineApple.";
   }

   function display(){
       echo "<br>Color:".$this->color;
       echo "<br>Taste:".$this->taste;
       echo "<br>Weight:".$this->weight;
   }
}


?>
<!DOCTYPE html>
<html>
<head>
   <title>PineApple</title>
</head>
<body>
<?php
   $A = new PineApple("blue", "salty", 23);
   $A->grow();
   $A->eat();
   $A->display();
   echo "<hr>";
   $B = new PineApple("yellow", "sweet", 11);
   $B->grow();
   $B->eat();
   $B->display();
?>
  
</body>
</html>

-------

------

Hastebin link in case code lose formatting: http://www.hastebin.com/tefahinato.xml


Related Solutions

Write a OOP class called BookList that uses a Book class and allows multiple books to...
Write a OOP class called BookList that uses a Book class and allows multiple books to be entered into a BookList object. Include normally useful methods and boolean addBook(Book b), Book searchBook(String title, String author). addBook returns true if b is successfully added to the list. searchBook returns a book matching either the title or author from the current list. You do not need to write Book (assume there are suitable constructors and methods) or any test code (main). You...
In a package named "oop" create a Scala class named "Score" with the following: • A...
In a package named "oop" create a Scala class named "Score" with the following: • A constructor that takes an Int and stores it in a member variable named score • A method named scoreGoal that takes no parameters and has return type Unit that increments the score by 1 • A method named isWinner that takes a Score object as a parameter and returns a Boolean. The method returns true if this instances score is strictly greater than the...
Question: In a package named "oop" create a Scala class named "Team" and a Scala object...
Question: In a package named "oop" create a Scala class named "Team" and a Scala object named "Referee". Team will have: • State values of type Int representing the strength of the team's offense and defense with a constructor to set these values. The parameters for the constructor should be offense then defense • A third state variable named "score" of type Int that is not in the constructor, is declared as a var, and is initialized to 0 Referee...
Create a java program that: - Has a class that defines an exception -Have that exception...
Create a java program that: - Has a class that defines an exception -Have that exception throw(n) in one method, and be caught and handled in another one. -Has a program that always continues even if incorrect data is entered by the user -has a minimum of 2 classes in it
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)    3. Assign your name as a string value into the variable labeled myName (Unit Objective 2)    4. Assign 53870 numeric value into the variable named randomNumber (Unit Objective 2) 5. ssign the name of the web browser and operating system of the...
Write a complete C++ program that defines, implements, and utilizes a Lion class and a Pine...
Write a complete C++ program that defines, implements, and utilizes a Lion class and a Pine class. Definition of classes from the implementation of the classes should be split. The program is made of five files: Lion.h, Lion.cpp, Pine.h, Pine.cpp, and TestLionPine.cpp. The components of Lion class are defined in the Lion.h file; however, all constructors and methods should not have any implementation code in this header file. All implementation code, i.e. constructor body and method body, should be written...
with PHP Create a class called Invoice that a hardware store might use to represent an...
with PHP Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables — a part number (type String), a part description (type String), a quantity of the item being purchased (type int) and a price per item (double). Your class should have a constructor that initializes the four instance variables. Provide a set and a get method...
Using PHP, Create a form that uses the method POST to send the information. The form...
Using PHP, Create a form that uses the method POST to send the information. The form should capture the distance the package needs to travel with the one field for the distance in miles. All fields should have the REQUIRED attribute. The form should have a submit button and reset button. The form should look nice. All the labels should line up horizontally and all the INPUTS/SELECT should line up horizontally.
With PHP Create a class called Account that a bank might use to represent customers' bank...
With PHP Create a class called Account that a bank might use to represent customers' bank accounts. Your class should include one data member of type int to represent the account balance. Your class should provide a constructor that receives an initial balance and uses it to initialize the data member. The constructor should validate the initial balance to ensure that it is greater than or equal to 0. If not, the balance should be set to 0 and the...
Complete the implementation of the Die class. Note that the Die class uses an array to...
Complete the implementation of the Die class. Note that the Die class uses an array to represent the faces of a die. You need to complete the no-argument constructor and the two methods compareTo and equals. Code: import java.util.Arrays; import java.util.Objects; import java.util.Random; /* * NOTE TO STUDENTS: * The constructor that you need to complete can be found on line 47. * * The two methods you need to complete can be found at the end of this file....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT