当前位置: 首页>>代码示例>>PHP>>正文


PHP Car类代码示例

本文整理汇总了PHP中Car的典型用法代码示例。如果您正苦于以下问题:PHP Car类的具体用法?PHP Car怎么用?PHP Car使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Car类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: buyCar

 public function buyCar(Car $car)
 {
     if ($this->getMoney() >= $car->getPrice()) {
         $this->setMoney($this->getMoney() - $car->getPrice());
         $this->setCar($car);
     }
 }
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:7,代码来源:Person.php

示例2: wordpress_setup

 function wordpress_setup() {
   $car = new Car();
   add_action('init',function() use ($car){
     register_taxonomy('car',array('fill'), $car->taxonomy());
   });
   add_action('template_include',function($template){
     global $wp,$wp_query;
     if($wp_query->query_vars['taxonomy']=='car'
       && isset($_SERVER['HTTP_X_REQUESTED_WITH'])
       && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest' 
       ){
       $new_template = locate_template( array( 'taxonomy-car_ajax.php' ) );
       if ( '' != $new_template ) {
         return $new_template ;
       }
     }
     elseif ($wp->request == 'car') {
       $new_template = locate_template( array( 'archive-car.php' ) );
       if ( '' != $new_template ) {
         return $new_template ;
       }
     }
     return $template;
   });
   return $this;
 }
开发者ID:0x3e,项目名称:cars,代码行数:26,代码来源:cars.php

示例3: testBridge

 public function testBridge()
 {
     $expect = "SssuuuuZzzuuuuKkiiiii";
     $car = new Car(new EngineSuzuki());
     $sound = $car->rase();
     $this->assertEquals($sound, $expect);
 }
开发者ID:AlexanderGrom,项目名称:php-patterns,代码行数:7,代码来源:bridge_test.php

示例4: isStreetLegal

 protected function isStreetLegal(Car $car)
 {
     if ($car->getMaximumSpeed() < $this->speedLimit) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ZSShang,项目名称:mylearn,代码行数:8,代码来源:Abstract01.php

示例5: copy

 public function copy()
 {
     $car = new Car();
     $car->setBody($this->getBody());
     $car->setWheel($this->getWheel());
     $car->setEngine($this->getEngine());
     return $car;
 }
开发者ID:nahidacm,项目名称:designpatterns,代码行数:8,代码来源:prototype.php

示例6: testCarPartsFactoryCreateEngineCalled

 public function testCarPartsFactoryCreateEngineCalled()
 {
     $hybridEngine = new HybridEngine();
     $factoryStub = $this->getMock('HybridCarPartsFactory');
     $factoryStub->expects($this->once())->method('createEngine')->will($this->returnValue($hybridEngine));
     $car = new Car($factoryStub);
     $car->start();
 }
开发者ID:karaatli,项目名称:the-learn-d-developer-design-patterns,代码行数:8,代码来源:AbstractFactoryTests.php

示例7: testName

 public function testName()
 {
     // Create new Car and pass in a name
     $car = new Car("Murcielago");
     // Get the car name
     $result = $car->name();
     // Assert that the name has been set correctly
     $this->assertEquals("Murcielago", $result);
 }
开发者ID:ruchidesai,项目名称:MyCakeApp,代码行数:9,代码来源:CarTest.php

示例8: testMaxSpeed

 public function testMaxSpeed()
 {
     $car = new Car();
     for ($i = 0; $i < 10; $i++) {
         $car->accelerate();
     }
     $this->assertEquals(100, $car->getSpeed());
     $car->accelerate();
     $this->assertEquals(100, $car->getSpeed());
 }
开发者ID:raynaldmo,项目名称:php-education,代码行数:10,代码来源:car_tests.php

示例9: withPriceandMaxspeed

 public static function withPriceandMaxspeed($model, $isSportsCar, $color, $price, $maxSpeed)
 {
     $car = new Car();
     $car->model = $model;
     $car->isSportscar = $isSportsCar;
     $car->color = $color;
     $car->setPrice($price);
     $car->setMaxspeed($maxSpeed);
     return $car;
 }
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:10,代码来源:Car.php

示例10: buyCar

 public function buyCar(Car $car)
 {
     if ($this->money >= $car->getPrice()) {
         $this->money -= $car->getPrice();
         echo ' Purchase successful!', PHP_EOL;
         $this->car = $car;
         $car->changeOwner($this);
         return $this->money;
     } else {
         echo ' You need more money! ';
     }
 }
开发者ID:nicoleip,项目名称:OOP_Homework,代码行数:12,代码来源:Person.php

示例11: buyCar

 public function buyCar($car)
 {
     $car = new Car();
     $carPrice = $car->getPrice();
     //return $car->getModel;
     if ($this->money > $carPrice) {
         $this->ownedCar = $car;
         return $carPrice;
         //$this->money -= $carPrice;
     } else {
         return $this->money;
     }
 }
开发者ID:ivanstoykovivanov,项目名称:IT_Talents_Homework_Classes,代码行数:13,代码来源:Person.php

示例12: shouldBeAbleToPopulateByJSON

 /**
  * @test
  */
 public function shouldBeAbleToPopulateByJSON()
 {
     // given
     $car = new Car(1);
     $this->assertEquals(1, $car->getId());
     $json = $car;
     $array = json_decode($json, true);
     // when
     $array['brand'] = 'BMW';
     $car->setValues($array);
     $car->commit();
     $newCar = new Car(1);
     // then
     $this->assertEquals('BMW', $newCar->getBrand());
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:18,代码来源:JSONTest.php

示例13: run

 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Car::create([]);
     }
 }
开发者ID:kenkode,项目名称:umash-1,代码行数:7,代码来源:CarsTableSeeder.php

示例14: run

 public function run()
 {
     $faker = Faker::create();
     $parking_lot = ParkingLot::all()->random();
     $car = Car::all()->random();
     $order = new Order();
     $order->parking_lot_id = $parking_lot->id;
     $order->car_id = $car->id;
     $order->stripe_customer_id = $faker->swiftBicNumber;
     $order->save();
     $parking_lot = ParkingLot::all()->random();
     $car = Car::all()->random();
     $order2 = new Order();
     $order2->parking_lot_id = $parking_lot->id;
     $order2->car_id = $car->id;
     $order2->stripe_customer_id = $faker->swiftBicNumber;
     $order2->save();
     $parking_lot = ParkingLot::all()->random();
     $car = Car::all()->random();
     $order3 = new Order();
     $order3->parking_lot_id = $parking_lot->id;
     $order3->car_id = $car->id;
     $order3->stripe_customer_id = $faker->swiftBicNumber;
     $order3->save();
 }
开发者ID:Park-It,项目名称:parkit.dev,代码行数:25,代码来源:OrdersTableSeeder.php

示例15: getAsArray

 public function getAsArray($redundantly = false)
 {
     if (isset($this->id) && (int) $this->id > 0) {
         $content = array();
         if (!is_null($this->text)) {
             $content['text'] = $this->text;
         } else {
             if (!is_null($this->image_id)) {
                 $domain = 'http' . (Request::server('HTTPS') ? '' : 's') . '://' . Request::server('HTTP_HOST');
                 $attachment = MessageAttachment::find($this->image_id);
                 $content['image'] = array('id' => (int) $attachment->id, 'thumb' => $domain . '/api/messages/attach/thumb/' . $attachment->id, 'origin' => $domain . '/api/messages/attach/gallery/' . $attachment->id, 'width' => $attachment->width, 'height' => $attachment->height);
             } else {
                 if (!is_null($this->car_id)) {
                     $car = Car::withTrashed()->find($this->car_id);
                     $content['car'] = array('id' => (int) $car->id, 'mark' => (int) $car->mark, 'model' => (int) $car->model, 'year' => (int) $car->year, 'color' => (int) $car->color, 'vehicle_type' => (int) $car->vehicle_type, 'body_type' => (int) $car->body_type);
                     if (!is_null($this->car_number)) {
                         $content['car']['number'] = $this->car_number;
                     }
                 } else {
                     if (!is_null($this->lat)) {
                         $content['geo'] = array('lat' => (double) $this->lat, 'long' => (double) $this->lng, 'location' => $this->location);
                     }
                 }
             }
         }
         if ($redundantly) {
             $user = User::find($this->user_id);
             return array('message_id' => (int) $this->id, 'chat_id' => (int) $this->chat_id, 'user' => array('id' => (int) $user->id, 'name' => $user->name, 'img' => array('middle' => $user->img_middle)), 'content' => $content, 'timestamp' => $this->getTimestamp(), 'delivered_at' => $this->delivered_at, 'viewed_at' => $this->viewed_at);
         } else {
             return array('message_id' => (int) $this->id, 'chat_id' => (int) $this->chat_id, 'user_id' => (int) $this->user_id, 'content' => $content, 'timestamp' => $this->getTimestamp(), 'delivered_at' => $this->delivered_at, 'viewed_at' => $this->viewed_at);
         }
     }
     return array();
 }
开发者ID:SenhorBardell,项目名称:yol,代码行数:34,代码来源:Message.php


注:本文中的Car类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。