Search Results

Search found 1058 results on 43 pages for 'car trader'.

Page 5/43 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Trying to implement a method that can compare any two lists but it always returns false

    - by Tyler Pfaff
    Hello like the title says I'm trying to make a method that can compare any two lists for equality. I'm trying to compare them in a way that validates that every element of one list has the same value as every element of another list. My Equals method below always returns false, can anyone see why that is? Thank you! using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; public class IEnumerableComparer<T> : IEqualityComparer<IEnumerable<T>> { public bool Equals(IEnumerable<T> x, IEnumerable<T> y) { for(int i = 0; i<x.Count();i++){ if(!Object.Equals(x.ElementAt(i), y.ElementAt(i))){ return false; } } return true; } public int GetHashCode(IEnumerable<T> obj) { if (obj == null) return 0; return unchecked(obj.Select(e => e.GetHashCode()).Aggregate(0, (a, b) => a + b)); } } Here is my data I'm using to test this Equals method. static void Main(string[] args) { Car car1 = new Car(); car1.make = "Toyota"; car1.model = "xB"; Car car2 = new Car(); car2.make = "Toyota"; car2.model = "xB"; List<Car> l1 = new List<Car>(); List<Car> l2 = new List<Car>(); l1.Add(car1); l2.Add(car2); IEnumerableComparer<Car> seq = new IEnumerableComparer<Car>(); bool b = seq.Equals(l1, l2); Console.Write(b); //always says false Console.Read(); } } Car class class Car { public String make { get; set; } public String model { get; set; } }

    Read the article

  • How can I make a simple path generator?

    - by user360737
    Hi all, I have a link that I have to repeat 50 times, for each folder, and I have 15 folders.the link that I have to repeat looks like this: <a href="update/images/Cars/car (x).JPG" rel="lightbox[cars]"></a> now, the jpg files are named car 1- car 50. and I would really like to be able to generate this script so that I can input the path "update/images/Cars/" the picture title (car) and the input the number of times that I need this link, and then have it spit out something that looks like this: <a href="update/images/Cars/car (1).JPG" rel="lightbox[cars]"></a> <a href="update/images/Cars/car (2).JPG" rel="lightbox[cars]"></a> <a href="update/images/Cars/car (3).JPG" rel="lightbox[cars]"></a> <a href="update/images/Cars/car (4).JPG" rel="lightbox[cars]"></a> <a href="update/images/Cars/car (5).JPG" rel="lightbox[cars]"></a> <a href="update/images/Cars/car (6).JPG" rel="lightbox[cars]"></a> and then it keeps repeating, I'm assuming this can be done with a counter, but I'm not sure. Thanks!

    Read the article

  • How to make a checkbox list that is also explorer tree?

    - by Loclip
    Lets say we have 3 categories Car Airplanes Bikes Each category have other categories for example car have: BMW Toyota Mercedes Each of these categories have cars (no more categories) Car, airplane, bikes will be items in the listbox that can be explored and checked. Now lets say we explore car there will be BMW, Toyota, Mercedes that can be only checked. So if I check car all car will be checked, if i check bmw only the bmw from cars will be checked.. How I can do that?

    Read the article

  • Finding greatest product of two lists, but keep getting #unspecific

    - by user1787030
    (define (greatest-product lst1 lst2) (define (helper lst addtimes total toacc) (cond ((null? lst) '()) ((= (countatoms lst) 1) (display total)) ((= addtimes (cadr lst)) (helper (cdr lst) 1 total total)) (else (helper lst (+ 1 addtimes) (+ toacc total) toacc)))) (cond ((> (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (helper lst1 0 0 (car lst1))) ((< (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (helper lst2 0 0 (car lst2))) ((= (helper lst1 0 0 (car lst1)) (helper lst2 0 0 (car lst2))) (display 'equal)))) Scheme keeps returning back that it cannot perform the procedure with #unspecific Im running it with (display (greatest-product '(1 2 3) '(4 5 6))) (display (greatest-product '(1 2 3) '(1 2 3))) (display (greatest-product '(1 2 3) '())) what is wrong with it? the problem seems to be occurring

    Read the article

  • Domain validates but won't save

    - by marko
    I have the following setup. Class, say, Car that has a CarPart (belongsTo=[car:Car]). When I'm creating a Car I also want to create som default CarParts, so I do def car = new Car(bla bla bla) def part = new CarPart(car:car) Now, when I do car.validate() or part.validate() it seems fine. But when I do if(car.save && part.save() I get this exception: 2012-03-24 14:02:21,943 [http-8080-4] ERROR util.JDBCExceptionReporter - Batch entry 0 insert into car_part (version, car_id, id) values ('0', '297', '298') was aborted. Call getNextException to see the cause. 2012-03-24 14:02:21,943 [http-8080-4] ERROR util.JDBCExceptionReporter - ERROR: value too long for type character varying(6) 2012-03-24 14:02:21,943 [http-8080-4] ERROR events.PatchedDefaultFlushEventListener - Could not synchronize database state with session org.hibernate.exception.DataException: Could not execute JDBC batch update Stacktrace follows: java.sql.BatchUpdateException: Batch entry 0 insert into car_part (version, deal_id, id) values ('0', '297', '298') was aborted. Call getNextException to see the cause. at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2621) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1837) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2754) at $Proxy20.flush(Unknown Source) at ristretto.DealController$_closure5.doCall(DealController.groovy:109) at ristretto.DealController$_closure5.doCall(DealController.groovy) at java.lang.Thread.run(Thread.java:722) Any ideas?

    Read the article

  • JQuery get id or class, not value

    - by Celia Tan
    I'm new at JQuery, what I wanted to ask is how to select an option, then another option will automatic selected that have property of first option. I've given code like this: <select name="kendaraan"> <option value="" selected>pilih kendaraan!</option> <option value="B 2011 DR" class="B2011DR">B 2011 DR</option> <option value="R 3333 OKI" class="R3333OKI">R 3333 OKI</option> <option value="k03">jazz</option> <option value="k04">innova</option> </select> <select name="driver"> <option value="" selected>pilih kendaraan!</option> <option value="s02" car="B2011DR" style="display:none">jojon</option> <option value="s01" car="B2011DR" style="display:none">mamat</option> <option value="s04" car="R3333OKI" style="display:none">tukul</option> <option value="s03" car="R3333OKI" style="display:none">mamat</option> <option value="s07" car="k03" style="display:none">bejo</option> <option value="s05" car="k03" style="display:none">mamat</option> <option value="s06" car="k03" style="display:none">tukul</option> <option value="s08" car="k04" style="display:none">budi</option> <option value="s09" car="">komeng</option> </select> $('select[name=kendaraan]').change(function() { //hide all option $('select[name=driver] option').css('display','none'); //display option only for matched driver var isCar = $('select[name=driver] option[car='+$(this).val()+']'); isCar.css('display','block'); //auto select first matched diriver $('select[name=driver]').val( $(isCar[0]).val() ) }) But the jquery code is for getting the value of "kendaraan", how to match it with the class, not the value?

    Read the article

  • REST API wrapper - class design for 'lite' object responses

    - by sasfrog
    I am writing a class library to serve as a managed .NET wrapper over a REST API. I'm very new to OOP, and this task is an ideal opportunity for me to learn some OOP concepts in a real-life situation that makes sense to me. Some of the key resources/objects that the API returns are returned with different levels of detail depending on whether the request is for a single instance, a list, or part of a "search all resources" response. This is obviously a good design for the REST API itself, so that full objects aren't returned (thus increasing the size of the response and therefore the time taken to respond) unless they're needed. So, to be clear: .../car/1234.json returns the full Car object for 1234, all its properties like colour, make, model, year, engine_size, etc. Let's call this full. .../cars.json returns a list of Car objects, but only with a subset of the properties returned by .../car/1234.json. Let's call this lite. ...search.json returns, among other things, a list of car objects, but with minimal properties (only ID, make and model). Let's call this lite-lite. I want to know what the pros and cons of each of the following possible designs are, and whether there is a better design that I haven't covered: Create a Car class that models the lite-lite properties, and then have each of the more detailed responses inherit and extend this class. Create separate CarFull, CarLite and CarLiteLite classes corresponding to each of the responses. Create a single Car class that contains (nullable?) properties for the full response, and create constructors for each of the responses which populate it to the extent possible (and maybe include a property that returns the response type from which the instance was created). I expect among other things there will be use cases for consumers of the wrapper where they will want to iterate through lists of Cars, regardless of which response type they were created from, such that the three response types can contribute to the same list. Happy to be pointed to good resources on this sort of thing, and/or even told the name of the concept I'm describing so I can better target my research.

    Read the article

  • bash script to delete old deployments

    - by benjwarner
    I have a directory where our deployments go. A deployment (which is itself a directory) is named in the format: <application-name>_<date> e.g. trader-gui_20091102 There are multiple applications deployed to this same parent directory, so the contents of the parent directory might look something like this: trader-gui_20091106 trader-gui_20091102 trader-gui_20091010 simulator_20091106 simulator_20091102 simulator_20090910 simulator_20090820 I want to write a bash script to clean out all deployments except for the most current of each application. (The most current denoted by the date in the name of the deployment). So running the bash script on the above parent directory would leave: trader-gui_20091106 simulator_20091106 Any help would be appreciated.

    Read the article

  • iPhone 4S Costs 50k In India. Heck! Rather I Buy Tata Nano Car For Twice The Money

    - by Gopinath
    Are you waiting to buy iPhone 4S in India? Stop waiting and start looking for alternatives as its going to be released in India with mind blowing price tags. A 16 GB iPhone 4S costs Rs. 44,500 + tax, 32 GB at 50,900 and the 64 GB..wait! Are you really interested to know the price? I’m not at all. Its ridiculous to spend 50,000 for a mobile phone in India. I hope majority of Indians agree with me. The Tata Nano, the world’s cheapest car, costs close to the double the price of iPhone 4S. Instead of buying an iPhone 4S for around 50K, it’s a wiser decision to buy a Tata Nano. Will the super rich of India afford to pay around 50,000 to own an iPhone 4S? I think they love to own it to show off their status but I guess they prefer to get it from US through their friends and relatives. In USA an unlocked iPhone 4S available through Apple Online Store costs just 33,500(~ 650 USD IN INR) and that is a straight away Rs. 11,000 discount. Why would the rich burn money? Airtel and Aircel has announced that the iPhone 4S is going to be available in their networks from November 25 onwards and both the operators started accepting the pre-orders. If you are really willing to burn your cash go ahead and book an iPhone 4S. This article titled,iPhone 4S Costs 50k In India. Heck! Rather I Buy Tata Nano Car For Twice The Money, was originally published at Tech Dreams. Grab our rss feed or fan us on Facebook to get updates from us.

    Read the article

  • transfering a container of data to different classes

    - by user340699
    I am passing a vector of bids from Trader class to Simulator class.which class then passes it on to the auctioneer class.something seems messed up, can anyone spot it please. Below is part of the code: Error: 199 expected primary-expression before '&' token //Class of Origin of the vector. class Trader { private: int nextBidId; public: Trader(); ~Trader(){}; Bid getNextBid(); Bid getNextBid(int trdId, int qty, int price, char type); void loadRange( vector <Bid> & bids ) {} ; void loadRange(BidList &, int trdId, int qty, int price, char type, int size); }; //To be received by the Simulator class Simulator { vector <Bid> list; Trader trader; Auctioneer auctioneer; public: void run(); }; // Passing the vector into a function in simulator Simulator::accept_bids(bid_vector::const_iterator begin, bid_vector::const_iterator end){ vector<Bid>::iterator itr; } //Its journey should end with the Auctioneer. who displays the data class Auctioneer { public: vector <Bid>v2;// created a new vector to hold the objects void accept_bids(vector<Bid> & bids); void displayBids(){return bids} };

    Read the article

  • Changes to data inside class not being shown when accessed from outside class.

    - by Hypatia
    I have two classes, Car and Person. Car has as one of its members an instance of Person, driver. I want to move a car, while keeping track of its location, and also move the driver inside the car and get its location. However, while this works from inside the class (I have printed out the values as they are calculated), when I try to access the data from main, there's nothing there. I.e. the array position[] ends up empty. I am wondering if there is something wrong with the way I have set up the classes -- could it be a problem of the scope of the object? I have tried simplifying the code so that I only give what is necessary. Hopefully that covers everything that you would need to see. The constructer Car() fills the offset array of driver with nonzero values. class Car{ public: Container(float=0,float=0,float=0); ~Container(); void move(float); void getPosition(float[]); void getDriverPosition(float[]); private: float position[3]; Person driver; float heading; float velocity; }; class Person{ public: Person(float=0,float=0,float=0); ~Person(); void setOffset(float=0,float=0,float=0); void setPosition(float=0,float=0,float=0); void getOffset(float[]); void getPosition(float[]); private: float position[3]; float offset[3]; }; Some of the functions: void Car::move(float time){ float distance = velocity*time; location[0] += distance*cos(PI/2 - heading); location[1] += distance*sin(PI/2 - heading); float driverLocation [3]; float offset[3]; driver->getOffset(offset); for (int i = 0; i < 3; i++){ driverLocation[i] = offset[i] + location[i]; } } void Car::getDriverPosition(float p[]){ driver.getPosition(p); } void Person::getPosition(float p[]){ for (int i = 0; i < 3; i++){ p[i] = position[i]; } } void Person::getOffset(float o[]){ for (int i = 0; i < 3; i++){ o[i] = offset[i]; } } In Main: Car * car = new Car(); car->move(); float p[3]; car->getDriverPosition(p); When I print driverLocation[] inside the move() function, I have actual nonzero values. When I print p[] inside main, all I get are zeros.

    Read the article

  • Not sure I am using inheritance/polymorphism issue?

    - by planker1010
    So for this assignment I have to create a car class(parent) and a certifiedpreowned (child) and I need to have the parent class have a method to check if it is still under warranty. *checkWarrantyStatus(). that method calls the boolean isCoveredUnderWarranty() to veryify if the car still has warranty. My issue is in the certifiedpreowned class I have to call the isCoveredUnderWarranty() as well to see if it is covered under the extended warranty and then have it be called via the checkWarrantyStatus() in the car method. I hope this makes sense. So to sum it up I need to in the child class have it check the isCoveredUnderWarranty with extended warranty info. Then it has to move to the parent class so it can be called via checkWarrantyStatus. Here is my code, I have 1 error. public class Car { public int year; public String make; public String model; public int currentMiles; public int warrantyMiles; public int warrantyYears; int currentYear =java.util.Calendar.getInstance().get(java.util.Calendar.YEAR); /** construct car object with specific parameters*/ public Car (int y, String m, String mod, int mi){ this.year = y; this.make = m; this.model = mod; this.currentMiles = mi; } public int getWarrantyMiles() { return warrantyMiles; } public void setWarrantyMiles(int warrantyMiles) { this.warrantyMiles = warrantyMiles; } public int getWarrantyYears() { return warrantyYears; } public void setWarrantyYears(int warrantyYears) { this.warrantyYears = warrantyYears; } public boolean isCoveredUnderWarranty(){ if (currentMiles < warrantyMiles){ if (currentYear < (year+ warrantyYears)) return true; } return false; } public void checkWarrantyStatus(){ if (isCoveredUnderWarranty()){ System.out.println("Your car " + year+ " " + make+ " "+ model+ " With "+ currentMiles +" is still covered under warranty"); } else System.out.println("Your car " + year+ " " + make+ " "+ model+ " With "+ currentMiles +" is out of warranty"); } } public class CertifiedPreOwnCar extends Car{ public CertifiedPreOwnCar(int y, String m, String mod, int mi) { super(mi, m, mod, y); } public int extendedWarrantyYears; public int extendedWarrantyMiles; public int getExtendedWarrantyYears() { return extendedWarrantyYears; } public void setExtendedWarrantyYears(int extendedWarrantyYears) { this.extendedWarrantyYears = extendedWarrantyYears; } public int getExtendedWarrantyMiles() { return extendedWarrantyMiles; } public void setExtendedWarrantyMiles(int extendedWarrantyMiles) { this.extendedWarrantyMiles = extendedWarrantyMiles; } public boolean isCoveredUnderWarranty() { if (currentMiles < extendedWarrantyMiles){ if (currentYear < (year+ extendedWarrantyYears)) return true; } return false; } } public class TestCar { public static void main(String[] args) { Car car1 = new Car(2014, "Honda", "Civic", 255); car1.setWarrantyMiles(60000); car1.setWarrantyYears(5); car1.checkWarrantyStatus(); Car car2 = new Car(2000, "Ferrari", "F355", 8500); car2.setWarrantyMiles(20000); car2.setWarrantyYears(7); car2.checkWarrantyStatus(); CertifiedPreOwnCar car3 = new CertifiedPreOwnCar(2000, "Honda", "Accord", 65000); car3.setWarrantyYears(3); car3.setWarrantyMiles(30000); car3.setExtendedWarrantyMiles(100000); car3.setExtendedWarrantyYears(7); car3.checkWarrantyStatus(); } }

    Read the article

  • JSF 2.0 AJAX: jsf.ajax.request to call method not only rerender an area of page

    - by gerry
    Hi, I'm looking for a soultion of the following problem: _The is a list of links with different types of cars. _The user can click on each car in the list and a ajax request should be sent. _The response of the ajax request should be dependent on the id (of each car) and displayed in an panelGroup. So what I need is a possibility to call a method on the backing-bean. Additionally, this method should be called with a car id as its parameter. My code so far looks like: ... <ul> <ui:repeat value="#{carTree.getCars)}" var="car"> <h:outputScript name="jsf.js" library="javax.faces" target="head" /> <li onclick="showDetails(#{car.id});">#{car.name}</li> </ui:repeat> </ul> ... <h:panelGroup id="carDetails" layout="block" style="float:left;"> // need the details of each 'selected /clicked' car here </h:panelGroup> ... And the method in the backing bean should look like: public class CarTree { ... public String getCarDetails(int carid){ return "The car details for the car id "+carid+" are......"; } ... } I've no idea how to call a method by using the new JSF 2.0 AJAX functionality. Please, help me...

    Read the article

  • Do ORMs normally allow circular relations? If so, how would they handle it?

    - by SeanJA
    I was hacking around trying to make a basic orm that has support for the one => one and one => many relationships. I think I succeeded somewhat, but I am curious about how to handle circular relationships. Say you had something like this: user::hasOne('car'); car::hasMany('wheels'); car::property('type'); wheel::hasOne('car'); You could then do this (theoretically): $u = new user(); echo $u->car->wheels[0]->car->wheels[1]->car->wheels[2]->car->wheels[3]->type; #=> "monster truck" Now, I am not sure why you would want to do this. It seems like it wastes a whole pile of memory and time just to get to something that could have been done in a much shorter way. In my small ORM, I now have 4 copies of the wheel class, and 4 copies of the car class in memory, which causes a problem if I update one of them and save it back to the database, the rest get out of date, and could overwrite the changes that were already made. How do other ORMs handle circular references? Do they even allow it? Do they go back up the tree and create a pointer to one of the parents? DO they let the coder shoot themselves in the foot if they are silly enough to go around in circles?

    Read the article

  • Abstract class + Inheritance vs Interface

    - by RealityDysfunction
    Hello fellow programmers, I am reading a book on C# and the author is comparing Abstract classes and Interfaces. He claims that if you have the following "abstract class:" abstract class CloneableType { public abstract object Clone(); } Then you cannot do this: public class MiniVan : Car, CloneableType {} This, I understand. However he claims that because of this inability to do multiple inheritance that you should use an interface for CloneableType, like so: public interface ICloneable { object Clone(); } My question is, isn't this somewhat misleading, because you can create an abstract class which is "above" class Car with the method Clone, then have Car inherit that class and then Minivan will inherit Car with all these methods, CloneAble class - Car class - Minivan Class. What do you think? Thanks.

    Read the article

  • Best URL for cars related website? [duplicate]

    - by Claudio ??is Mulas
    This question already has an answer here: What is the best stucture of SEO friendly URL? 3 answers If this was your website, what will be the URLs for each car on sale? http://www.autoscout24.eu/Details.aspx?id=247572735&asrc=ha I'm working on a car dealership website. What should be the best URL? Consider also that the company can have more models of the same car. I'm not asking for a url scheme, there are a lot of similar questions. My question is: in a car dealership website what is the best url for a car? What are by you the best variables I've to put on the url. Brand, model, year, location, color, miles/km, etc. This website, that url, this particulary case: what will you choose for urls? (even not in the following list) audi_q5_2009.html audi_q5_2009_used.html audi_q5_2009_used.html audi_q5_2009_used_in_alcobendas.html audi_q5_2009_used/247572735.html

    Read the article

  • How to structure controller to sort multiple criteria asp.net mvc

    - by Solomon
    Hi, What's the best way to set up a controller to sort by many (possibly null) criteria? Say for example, I was building a site that sold cars. My CarController has a function Index() which returns an IList of cars to the view, and details on each car are rendered with a partial view. What's the best way to structure this? Especially if there are a lot of criteria: Car Type (aka SUV), Car Brand, Car Model, Car Year, Car Price, Car Color, bool IsNew, or if I want to sort by closest to me etc... I'm using NHibernate as my ORM. Should I have just a ton of possible NHibernate queries and figure out which one to choose based on if/then's in the controller? Or is there a simpler way. Thanks so much for the help.

    Read the article

  • How Can I Improve This Algorithm (LCS)

    - by superguay
    (define (lcs lst1 lst2) (define (except-last-pair list) (if (pair? (cdr list)) (cons (car list) (except-last-pair (cdr list))) '())) (define (car-last-pair list) (if (pair? (cdr list)) (car-last-pair (cdr list)) (car list))) (if (or (null? lst1) (null? lst2)) null (if (= (car-last-pair lst1) (car-last-pair lst2)) (append (lcs (except-last-pair lst1) (except-last-pair lst2)) (cons (car-last-pair lst1) '())) **(if (> (length (lcs lst1 (except-last-pair lst2))) (length (lcs lst2 (except-last-pair lst1)))) (lcs lst1 (except-last-pair lst2)) (lcs lst2 (except-last-pair lst1)))))) I dont want it to run over and over.. Regards, Superguay

    Read the article

  • Entity framework Update fails when object is linked to a missing child

    - by McKay
    I’m having trouble updating an objects child when the object has a reference to a nonexising child record. eg. Tables Car and CarColor have a relationship. Car.CarColorId CarColor.CarColorId If I load the car with its color record like so this var result = from x in database.Car.Include("CarColor") where x.CarId = 5 select x; I'll get back the Car object and it’s Color object. Now suppose that some time ago a CarColor had been deleted but the Car record in question still contains the CarColorId value. So when I run the query the Color object is null because the CarColor record didn’t exist. My problem here is that when I attach another Color object that does exist I get a Store update, insert error when saving. Car.Color = newColor Database.SaveChanges(); It’s like the context is trying to delete the nonexisting color. How can I get around this?

    Read the article

  • Many Buttons on a Page, Need to send back Unique Post Data with each

    - by CoffeeAddict
    I'm listing out a bunch of cars with a button next to them that when clicked will need to perform a GET but also sends over that item's model.Name: @using (Html.BeginForm("GetCarUrl", "Car", FormMethod.Get, new { model = Model })) { if(Model.Cars != null && Model.Cars.Count > 0) { foreach (CarContent car in Model.Cars) { <p>@car.Name</p> } <input type="button" value="Get Car Url" class="submit" /> } So the page renders a bunch of hyperlinks and buttons: [hyperlink1] [submit] [hyperlink2] [submit] [hyperlink3] [submit] [hyperlink4] [submit] [hyperlink5] [submit] ... When a user clicks on any of the submits, I need to pass back its corresponding @car.CarType for that specific hyperlink Not sure how to go about this. My action method expects a @car.CarType for that specific car hyperlink to be sent to it

    Read the article

  • Java multiple class compositing and boiler plate reduction

    - by h2g2java
    We all know why Java does/should not have multiple inheritance. So this is not questioning about what has already been debated till-cows-come-home. This discusses what we would do when we wish to create a class that has the characteristics of two or more other classes. Probably, most of us would do this to "inherit" from three classes. For simplicity, I left out the constructor.: class Car extends Vehicle { final public Transport transport; final public Machine machine; } So that, Car class directly inherits methods and objects of Vehicle class, but would have to refer to transport and machine explicitly to refer to objects instantiated in Transport and Machine. Car car = new Car(); car.drive(); // from Vehicle car.transport.isAmphibious(); // from Transport car.machine.getCO2Footprint(); // from Machine I thought this was a good idea until when I encounter frameworks that require setter and getter methods. For example, the XML <Car amphibious='false' footPrint='1000' model='Fordstatic999'/> would look for the methods setAmphibious(..), setFootPrint(..) and setModel(..). Therefore, I have to project the methods from Transport and Machine classes class Car extends Vehicle { final public Transport transport; final public Machine machine; public void setAmphibious(boolean b){ this.transport.setAmphibious(b); } public void setFootPrint(String fp){ this.machine.setFootPrint(fp); } } This is OK, if there were just a few characteristics. Right now, I am trying to adapt all of SmartGWT into GWT UIBinder, especially those classes that are not a GWT widget. There are lots of characteristics to project. Wouldn't it be nice if there exists some form of annotation framework that is like this: class Car extends Vehicle @projects {Transport @projects{Machine @projects Guzzler}} { /* No need to explicitly instantiate Transport, Machine or Guzzler */ .... } Where, in case of common names of characteristics exist, the characteristics of Machine would take precedence Guzzler's, and Transport's would have precedence over Machine's, and Vehicle's would have precedence over Transport's. The annotation framework would then instantiate Transport, Machine and Guzzler as hidden members of Car and expand to break-out the protected/public characteristics, in the precedence dictated by the @project annotation sequence, into actual source code or into byte-code. Preferably into byte-code. So that the setFootPrint method is found in both Machine and Guzzler, only that of Machine's would be projected. Questions: Don't you think this is a good idea to have such a framework? Does such a framework already exist? Tell me where/what. Is there an eclipse plugin that does it? Is there a proposal or plan anywhere that you know about such an annotation framework? It would be wonderful too, if the annotation/plugin framework lets me specify that boolean, int, or whatever else needs to be converted from String and does the conversion/parsing for me too. Please advise, somebody. I hope wording of my question was clear enough. Thx. Edited: To avoid OO enthusiasts jumping to conclusion, I have renamed the title of this question.

    Read the article

  • LINQ: Single vs. First

    - by Paulo Morgado
    I’ve witnessed and been involved in several discussions around the correctness or usefulness of the Single method in the LINQ API. The most common argument is that you are querying for the first element on the result set and an exception will be thrown if there’s more than one element. The First method should be used instead, because it doesn’t throw if the result set has more than one item. Although the documentation for Single states that it returns a single, specific element of a sequence of values, it actually returns THE single, specific element of a sequence of ONE value. One you use the Single method in your code you are asserting that your query will result in a scalar result instead of a result set of arbitrary length. On the other hand, the documentation for First states that it returns the first element of a sequence of arbitrary length. Imagine you want to catch a taxi. You go the the taxi line and catch the FIRST one, no matter how many are there. On the other hand, if you go the the parking lot to get your car, you want the SINGLE one specific car that’s yours. If your “query” “returns” more than one car, it’s an exception. Either because it “returned” not only your car or you happen to have more than one car in that parking lot. In either case, you can only drive one car at once and you’ll need to refine your “query”.

    Read the article

  • How to implement curved movement while tracking the appropriate angle?

    - by Vexille
    I'm currently coding a 2D top-down car game which will be turn-based. And since it's turn-based, the cars won't be controlled directly (i.e. with a simple velocity vector that adjusts its angle when the player wants to turn), but instead it's movement path has to be planned beforehand, and then the car needs to follow the path when the turn ends (think Steambirds). This question has some interesting information, but its focus is on homing-missile behaviour, which I kinda had figured out, but doesn't really apply to my case, I think, since I need to show a preview of the path when the player is planning his turn, then have the car follow that path. In that same question, there's an excellent answer by Andrew Russel which mentions Equations of Motion and Bézier's Curve. Some of his other suggestions of implementation are specific to XNA though, so they don't help much (I'm using Marmalade SDK). If I assume Bézier's Curve as the solution of choice, I'm left with one specific problem: I'll have the car's position (the first endpoint) and the target/final position (the last endpoint), but what should I use as the control point (assuming a square/quadratic curve)? And whether I use Bézier's Curve or another parametric equation, I'd still be left with another issue: the car can't just follow the curve, it must turn (i.e. adjust its angle) accordingly. So how can I figure out which way the car should be pointing to at any given point in the curve?

    Read the article

  • Variant Management– Which Approach fits for my Product?

    - by C. Chadwick
    Jürgen Kunz – Director Product Development – Oracle ORACLE Deutschland B.V. & Co. KG Introduction In a difficult economic environment, it is important for companies to understand the customer requirements in detail and to address them in their products. Customer specific products, however, usually cause increased costs. Variant management helps to find the best combination of standard components and custom components which balances customer’s product requirements and product costs. Depending on the type of product, different approaches to variant management will be applied. For example the automotive product “car” or electronic/high-tech products like a “computer”, with a pre-defined set of options to be combined in the individual configuration (so called “Assembled to Order” products), require a different approach to products in heavy machinery, which are (at least partially) engineered in a customer specific way (so-called “Engineered-to Order” products). This article discusses different approaches to variant management. Starting with the simple Bill of Material (BOM), this article presents three different approaches to variant management, which are provided by Agile PLM. Single level BOM and Variant BOM The single level BOM is the basic form of the BOM. The product structure is defined using assemblies and single parts. A particular product is thus represented by a fixed product structure. As soon as you have to manage product variants, the single level BOM is no longer sufficient. A variant BOM will be needed to manage product variants. The variant BOM is sometimes referred to as 150% BOM, since a variant BOM contains more parts and assemblies than actually needed to assemble the (final) product – just 150% of the parts You can evolve the variant BOM from the single level BOM by replacing single nodes with a placeholder node. The placeholder in this case represents the possible variants of a part or assembly. Product structure nodes, which are part of any product, are so-called “Must-Have” parts. “Optional” parts can be omitted in the final product. Additional attributes allow limiting the quantity of parts/assemblies which can be assigned at a certain position in the Variant BOM. Figure 1 shows the variant BOM of Agile PLM. Figure 1 Variant BOM in Agile PLM During the instantiation of the Variant BOM, the placeholders get replaced by specific variants of the parts and assemblies. The selection of the desired or appropriate variants is either done step by step by the user or by applying pre-defined configuration rules. As a result of the instantiation, an independent BOM will be created (Figure 2). Figure 2 Instantiated BOM in Agile PLM This kind of Variant BOM  can be used for „Assembled –To-Order“ type products as well as for „Engineered-to-Order“-type products. In case of “Assembled –To-Order” type products, typically the instantiation is done automatically with pre-defined configuration rules. For „Engineered- to-Order“-type products at least part of the product is selected manually to make use of customized parts/assemblies, that have been engineered according to the specific custom requirements. Template BOM The Template BOM is used for „Engineered-to-Order“-type products. It is another type of variant BOM. The engineer works in a flexible environment which allows him to build the most creative solutions. At the same time the engineer shall be guided to re-use existing solutions and it shall be assured that product variants of the same product family share the same base structure. The template BOM defines the basic structure of products belonging to the same product family. Let’s take a gearbox as an example. The customer specific configuration of the gearbox is influenced by several parameters (e.g. rpm range, transmitted torque), which are defined in the customer’s requirement document.  Figure 3 shows part of a Template BOM (yellow) and its relation to the product family hierarchy (blue).  Figure 3 Template BOM Every component of the Template BOM has links to the variants that have been engineeried so far for the component (depending on the level in the Template BOM, they are product variants, Assembly Variant or single part variants). This library of solutions, the so-called solution space, can be used by the engineers to build new product variants. In the best case, the engineer selects an existing solution variant, such as the gearbox shown in figure 3. When the existing variants do not fulfill the specific requirements, a new variant will be engineered. This new variant must be compliant with the given Template BOM. If we look at the gearbox in figure 3  it must consist of a transmission housing, a Connecting Plate, a set of Gears and a Planetary transmission – pre-assumed that all components are must have components. The new variant will enhance the solution space and is automatically available for re-use in future variants. The result of the instantiation of the Template BOM is a stand-alone BOM which represents the customer specific product variant. Modular BOM The concept of the modular BOM was invented in the automotive industry. Passenger cars are so-called „Assembled-to-Order“-products. The customer first selects the specific equipment of the car (so-called specifications) – for instance engine, audio equipment, rims, color. Based on this information the required parts will be determined and the customer specific car will be assembled. Certain combinations of specification are not available for the customer, because they are not feasible from technical perspective (e.g. a convertible with sun roof) or because the combination will not be offered for marketing reasons (e.g. steel rims with a sports line car). The modular BOM (yellow structure in figure 4) is defined in the context of a specific product family (in the sample it is product family „Speedstar“). It is the same modular BOM for the different types of cars of the product family (e.g. sedan, station wagon). The assembly or single parts of the car (blue nodes in figure 4) are assigned at the leaf level of the modular BOM. The assignment of assembly and parts to the modular BOM is enriched with a configuration rule (purple elements in figure 4). The configuration rule defines the conditions to use a specific assembly or single part. The configuration rule is valid in the context of a type of car (green elements in figure 4). Color specific parts are assigned to the color independent parts via additional configuration rules (grey elements in figure 4). The configuration rules use Boolean operators to connect the specifications. Additional consistency rules (constraints) may be used to define invalid combinations of specification (so-called exclusions). Furthermore consistency rules may be used to add specifications to the set of specifications. For instance it is important that a car with diesel engine always is build using the high capacity battery.  Figure 4 Modular BOM The calculation of the car configuration consists of several steps. First the consistency rules (constraints) are applied. Resulting from that specification might be added automatically. The second step will determine the assemblies and single parts for the complete structure of the modular BOM, by evaluating the configuration rules in the context of the current type of car. The evaluation of the rules for one component in the modular BOM might result in several rules being fulfilled. In this case the most specific rule (typically the longest rule) will win. Thanks to this approach, it is possible to add a specific variant to the modular BOM without the need to change any other configuration rules.  As a result the whole set of configuration rules is easy to maintain. Finally the color specific assemblies respective parts will be determined and the configuration is completed. Figure 5 Calculated Car Configuration The result of the car configuration is shown in figure 5. It shows the list of assemblies respective single parts (blue components in figure 5), which are required to build the customer specific car. Summary There are different approaches to variant management. Three different approaches have been presented in this article. At the end of the day, it is the type of the product which decides about the best approach.  For „Assembled to Order“-type products it is very likely that you can define the configuration rules and calculate the product variant automatically. Products of type „Engineered-to-Order“ ,however, need to be engineered. Nevertheless in the majority of cases, part of the product structure can be generated automatically in a similar way to „Assembled to Order“-tape products.  That said it is important first to analyze the product portfolio, in order to define the best approach to variant management.

    Read the article

  • Does code in the constructor add to code in subclass constructors?

    - by Jeremy Rudd
    Does code in the constructor add to code in subclass constructors? Or does the subclass's constructor override the superclass? Given this example superclass constructor: class Car{ function Car(){ trace("CAR") } } ...and this subclass constructor: class FordCar extends Car{ function FordCar(){ trace("FORD") } } When an instance of FordCar is created, will this trace "Car" and "Ford" ??

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >