Search Results

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

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

  • Saving associated domain classes in Grails

    - by Cesar
    I'm struggling to get association right on Grails. Let's say I have two domain classes: class Engine { String name int numberOfCylinders = 4 static constraints = { name(blank:false, nullable:false) numberOfCylinders(range:4..8) } } class Car { int year String brand Engine engine = new Engine(name:"Default Engine") static constraints = { engine(nullable:false) brand(blank:false, nullable:false) year(nullable:false) } } The idea is that users can create cars without creating an engine first, and those cars get a default engine. In the CarController I have: def save = { def car = new Car(params) if(!car.hasErrors() && car.save()){ flash.message = "Car saved" redirect(action:index) }else{ render(view:'create', model:[car:car]) } } When trying to save, I get a null value exception on the Car.engine field, so obviously the default engine is not created and saved. I tried to manually create the engine: def save = { def car = new Car(params) car.engine = new Engine(name: "Default Engine") if(!car.hasErrors() && car.save()){ flash.message = "Car saved" redirect(action:index) }else{ render(view:'create', model:[car:car]) } } Didn't work either. Is Grails not able to save associated classes? How could I implement such feature?

    Read the article

  • car race game collision condition.

    - by ashok patidar
    in this how can rotate car when it goes to collied with the track side. package { import flash.display.MovieClip; import flash.events.Event; import flash.events.KeyboardEvent; import flash.text.TextField; import flash.ui.Keyboard; import Math; /** * ... * @author Ashok */ public class F1race extends MovieClip { public var increment:Number = 0; //amount the car moves each frame public var posNeg:Number = 1; public var acceleration:Number = .05; //acceleration of the car, or the amount increment gets increased by. public var speed:Number = 0; //the speed of the car that will be displayed on screen public var maxSpeed:Number = 100; public var keyLeftPressed:Boolean; public var keyRightPressed:Boolean; public var keyUpPressed:Boolean; public var keyDownPressed:Boolean; public var spedometer:TextField = new TextField(); public var carRotation:Number ; public var txt_hit:TextField = new TextField(); public function F1race() { carRotation = carMC.rotation; trace(carMC.rotation); //addChild(spedometer); //spedometer.x = 0; //spedometer.y = 0; addChild(txt_hit); txt_hit.x = 0; txt_hit.y = 100; //rotation of the car addEventListener(Event.ENTER_FRAME, onEnterFrameFunction); stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed,false); stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased,false); carMC.addEventListener(Event.ENTER_FRAME, carOver_road) } public function carOver_road(event:Event):void { //trace(texture.hitTestPoint(carMC.x,carMC.y,true),"--"); /* if(!texture.hitTestPoint(carMC.x,carMC.y,true)) { txt_hit.text = "WRONG WAY"; if(increment!=0) { increment=1; } } else { txt_hit.text = ""; //increment++; }*/ if (roadless.hitTestPoint(carMC.x - carMC.width / 2, carMC.y,true)) { trace("left Hit" + carMC.rotation); //acceleration = .005; //if(carMC.rotation>90 || carMC.rotation>90 //carMC.rotation += 2; if ((carMC.rotation >= 90) && (carMC.rotation <= 180)) { carMC.rotation += 3; carMC.x += 3; } if ((carMC.rotation <= -90) && (carMC.rotation >= -180)) { carMC.rotation += 3; texture.y -= 3; } if ((carMC.rotation > -90) && (carMC.rotation <= -1)) { carMC.rotation += 3; texture.y -= 3; } if(increment<0) { increment += 1.5 * acceleration; } if(increment>0) { increment -= 1.5 * acceleration; } } if (roadless.hitTestPoint(carMC.x + carMC.width / 2, carMC.y,true)) { trace("left right"); //carMC.rotation -= 2; if(increment<0) { increment += 1.5 * acceleration; } if(increment>0) { increment -= 1.5 * acceleration; } } if (roadless.hitTestPoint(carMC.x, carMC.y- carMC.height / 2,true)) { trace("left right"); //carMC.rotation -= 2; if(increment<0) { increment += 1.5 * acceleration; } if(increment>0) { increment -= 1.5 * acceleration; } } if (roadless.hitTestPoint(carMC.x, carMC.y+ carMC.height / 2,true)) { trace("left right"); //carMC.rotation -= 2; if(increment<0) { increment += 1.5 * acceleration; } if(increment>0) { increment -= 1.5 * acceleration; } } if ((!roadless.hitTestPoint(carMC.x - carMC.width / 2, carMC.y, true)) && (!roadless.hitTestPoint(carMC.x, carMC.y- carMC.height / 2,true)) && (!roadless.hitTestPoint(carMC.x, carMC.y+ carMC.height / 2,true)) && (!roadless.hitTestPoint(carMC.x, carMC.y+ carMC.height / 2,true))) { //acceleration = .05; } } public function onEnterFrameFunction(events:Event):void { speed = Math.round((increment) * 5); spedometer.text = String(speed); if ((carMC.rotation < 180)&&(carMC.rotation >= 0)){ carRotation = carMC.rotation; posNeg = 1; } if ((carMC.rotation < 0)&&(carMC.rotation > -180)){ carRotation = -1 * carMC.rotation; posNeg = -1; } if (keyRightPressed) { carMC.rotation += .5 * increment; carMC.LWheel.rotation = 8; carMC.RWheel.rotation = 8; steering.gotoAndStop(2); } if (keyLeftPressed) { carMC.rotation -= .5 * increment; carMC.LWheel.rotation = -8; carMC.RWheel.rotation = -8; steering.gotoAndStop(3); } if (keyDownPressed) { steering.gotoAndStop(1); carMC.LWheel.rotation = 0; carMC.RWheel.rotation = 0; increment -= 0.5 * acceleration; texture.y -= ((90 - carRotation) / 90) * increment; roadless.y = texture.y; if (((carMC.rotation > 90)&&(carMC.rotation < 180))||((carMC.rotation < -90)&&(carMC.rotation > -180))) { texture.x += posNeg * (((((1 - (carRotation / 360)) * 360) - 180) / 90) * increment); roadless.x = texture.x; } if (((carMC.rotation <= 90)&&(carMC.rotation > 0))||((carMC.rotation >= -90)&&(carMC.rotation < -1))) { texture.x += posNeg * ((carRotation) / 90) * increment; roadless.x = texture.x; } increment -= 1 * acceleration; if ((Math.abs(speed)) < (Math.abs(maxSpeed))) { increment += acceleration; } if ((Math.abs(speed)) == (Math.abs(maxSpeed))) { trace("hello"); } } if (keyUpPressed) { steering.gotoAndStop(1); carMC.LWheel.rotation = 0; carMC.RWheel.rotation = 0; //trace(carMC.rotation); texture.y -= ((90 - carRotation) / 90) * increment; roadless.y = texture.y; if (((carMC.rotation > 90)&&(carMC.rotation < 180))||((carMC.rotation < -90)&&(carMC.rotation > -180))) { texture.x += posNeg * (((((1 - (carRotation / 360)) * 360) - 180) / 90) * increment); roadless.x = texture.x; } if (((carMC.rotation <= 90)&&(carMC.rotation > 0))||((carMC.rotation >= -90)&&(carMC.rotation < -1))) { texture.x += posNeg * ((carRotation) / 90) * increment; roadless.x = texture.x; } increment += 1 * acceleration; if ((Math.abs(speed)) < (Math.abs(maxSpeed))) { increment += acceleration; } } if ((!keyUpPressed) && (!keyDownPressed)){ /*if (increment > 0 && (!keyUpPressed)&& (!keyDownPressed)) { //texture.y -= ((90-carRotation)/90)*increment; increment -= 1.5 * acceleration; } if((increment==0)&&(!keyUpPressed)&& (!keyDownPressed)) { increment = 0; } if((increment<0)&&(!keyUpPressed)&& (!keyDownPressed)) { increment += 1.5 * acceleration; }*/ if (increment > 0) { increment -= 1.5 * acceleration; texture.y -= ((90 - carRotation) / 90) * increment; roadless.y = texture.y; if (((carMC.rotation > 90)&&(carMC.rotation < 180))||((carMC.rotation < -90)&&(carMC.rotation > -180))) { texture.x += posNeg * (((((1 - (carRotation / 360)) * 360) - 180) / 90) * increment); roadless.x = texture.x; } if (((carMC.rotation <= 90)&&(carMC.rotation > 0))||((carMC.rotation >= -90)&&(carMC.rotation < -1))) { texture.x += posNeg * ((carRotation) / 90) * increment; roadless.x = texture.x; } } if (increment == 0) { increment = 0; } if (increment < 0) { increment += 1.5 * acceleration; texture.y -= ((90 - carRotation) / 90) * increment; roadless.y = texture.y; if (((carMC.rotation > 90)&&(carMC.rotation < 180))||((carMC.rotation < -90)&&(carMC.rotation > -180))) { texture.x += posNeg * (((((1 - (carRotation / 360)) * 360) - 180) / 90) * increment); roadless.x = texture.x; } if (((carMC.rotation <= 90)&&(carMC.rotation > 0))||((carMC.rotation >= -90)&&(carMC.rotation < -1))) { texture.x += posNeg * ((carRotation) / 90) * increment; roadless.x = texture.x; } } } } public function keyPressed(event:KeyboardEvent):void { trace("keyPressed"); if (event.keyCode == Keyboard.LEFT) { keyLeftPressed = true; } if (event.keyCode == Keyboard.RIGHT) { keyRightPressed = true; } if (event.keyCode == Keyboard.UP) { keyUpPressed = true; } if (event.keyCode == Keyboard.DOWN) { keyDownPressed = true; } } public function keyReleased(event:KeyboardEvent):void { trace("keyReleased..."); //increment -= 1.5 * acceleration; //increment--; if (event.keyCode == Keyboard.LEFT) { keyLeftPressed = false; } if (event.keyCode == Keyboard.RIGHT) { keyRightPressed = false; } if (event.keyCode == Keyboard.UP) { keyUpPressed = false; } if (event.keyCode == Keyboard.DOWN) { keyDownPressed = false; } } } }

    Read the article

  • Complicated idea - how to create car racing for my RPG game's players

    - by Donator
    So, I want to create car racing for my RPG game's players. Player can create race and choose how many participants can participate in race. After race is being created, other people can join it. When the maximum participants are collected, race begins. My idea, when the last participant joins, then instantly choose the winner (who's car is the best, that person wins), but how can I do it? If I choose to pick the winner after the last participant joins, then I have to put many queries in one page (select data from table, then delete the race, then select players' cars' statistics and pick the winner and then again, using mysql, send message to everyone). But this idea is really not optimal and it will lag cruelly for that last person. Maybe you have any ideas how I can avoid lag and make it more optimal. Thank you very much.

    Read the article

  • JSF : able to do mass update but unable to update a single row in a datatable

    - by nash
    I have a simple data object: Car. I am showing the properties of Car objects in a JSF datatable. If i display the properties using inputText tags, i am able to get the modified values in the managed bean. However i just want a single row editable. So have placed a edit button in a separate column and inputText and outputText for every property of Car. the edit button just toggles the rendering of inputText and outputText. Plus i placed a update button in a separate column which is used to save the updated values. However on clicking the update button, i still get the old values instead of the modified values. Here is the complete code: public class Car { int id; String brand; String color; public Car(int id, String brand, String color) { this.id = id; this.brand = brand; this.color = color; } //getters and setters of id, brand, color } Here is the managed bean: import java.util.ArrayList; import java.util.List; import javax.faces.bean.ManagedBean; import javax.faces.bean.RequestScoped; import javax.faces.component.UIData; @ManagedBean(name = "CarTree") @RequestScoped public class CarTree { int editableRowId; List<Car> carList; private UIData myTable; public CarTree() { carList = new ArrayList<Car>(); carList.add(new Car(1, "jaguar", "grey")); carList.add(new Car(2, "ferari", "red")); carList.add(new Car(3, "camri", "steel")); } public String update() { System.out.println("updating..."); //below statments print old values, was expecting modified values System.out.println("new car brand is:" + ((Car) myTable.getRowData()).brand); System.out.println("new car color is:" + ((Car) myTable.getRowData()).color); //how to get modified row values in this method?? return null; } public int getEditableRowId() { return editableRowId; } public void setEditableRowId(int editableRowId) { this.editableRowId = editableRowId; } public UIData getMyTable() { return myTable; } public void setMyTable(UIData myTable) { this.myTable = myTable; } public List<Car> getCars() { return carList; } public void setCars(List<Car> carList) { this.carList = carList; } } here is the JSF 2 page: <?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <h:head> <title>Facelet Title</title> </h:head> <h:body> <h:form id="carForm" prependId="false"> <h:dataTable id="dt" binding="#{CarTree.myTable}" value="#{CarTree.cars}" var="car" > <h:column> <h:outputText value="#{car.id}" /> </h:column> <h:column> <h:outputText value="#{car.brand}" rendered="#{CarTree.editableRowId != car.id}"/> <h:inputText value="#{car.brand}" rendered="#{CarTree.editableRowId == car.id}"/> </h:column> <h:column> <h:outputText value="#{car.color}" rendered="#{CarTree.editableRowId != car.id}"/> <h:inputText value="#{car.color}" rendered="#{CarTree.editableRowId == car.id}"/> </h:column> <h:column> <h:commandButton value="edit"> <f:setPropertyActionListener target="#{CarTree.editableRowId}" value="#{car.id}" /> </h:commandButton> </h:column> <h:column> <h:commandButton value="update" action="#{CarTree.update}"/> </h:column> </h:dataTable> </h:form> </h:body> </html> However if i just keep the inputText tags and remove the rendered attributes, i get the modified values in the update method. How can i get the modified values for the single row edit?

    Read the article

  • Tablet as Car Computer

    - by Austin Fitzpatrick
    Okay, so forward this off to the right place if this isn't the right place to ask this question. I want to use a tablet computer as a car-computer. Minimum features would be to run my music (through iPod, Pandora, whatever I want) and GPS Navigation, watch TV or movies while I'm parked waiting for people, and the hard one: it needs to answer my phone calls with a pleasant interface much like in-dash systems do. It needs to detect that my phone is ringing in my pocket and provide an on-screen answer/ignore and then route the audio through the cars speakers. It would be nice to dial out and have address book access, but that is somewhat secondary. I have an iPhone myself and I figured that an iPad with 3G might make a good system for this - but I'm open to other options if an iPad can't do everything I need. I'm willing to write code, and I'm willing to jailbreak one or both devices. I haven't done much work in Obj-C, but I'm not opposed to learning a new language for this project. It's self enrichment for the most part, as I'm sure I can buy an indash entertainment system for less. Does anyone have experience with the iPhone/iPad SDK that can tell me whether or not it would be possible to get it an iPad to answer my calls in the car? What about an Android tablet? (that Adam looks promising, too).

    Read the article

  • App will not launch from drawer after phone is removed from car dock

    - by BigFwoosh
    I am creating a replacement Car Home app for Android 2.0+ devices. The app needs to launch when the phone is inserted into the car dock, as well as terminate when it is removed from the dock. It also needs to be able to be launched from the app drawer. I'm having a problem right now where once the phone is inserted and removed from the dock, I can no longer launch the app from the app drawer because every time I launch the app my BroadcastReceiver picks up a DOCK_EVENT action for some reason. I created a test project that only registers my BroadcastReceiver, and the same thing happens. Here's the code for the BroadcastReceiver: public class CarDockBroadcastReceiver extends BroadcastReceiver { /** * @see android.content.BroadcastReceiver#onReceive(Context,Intent) */ @Override public void onReceive(Context context, Intent intent) { // TODO Put your code here if(intent.getExtras().containsKey("android.intent.extra.DOCK_STATE")){ int state = intent.getExtras().getInt("android.intent.extra.DOCK_STATE",1); if(state == 0){ Log.i("Dock", "Removed from dock!"); ((Activity)context).finish(); } } } } My main Activity is as follows: public class MainActivity extends Activity { /** Called when the activity is first created. */ CarDockBroadcastReceiver receiver; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); IntentFilter filter = new IntentFilter("android.intent.action.DOCK_EVENT"); receiver = new CarDockBroadcastReceiver(); registerReceiver(receiver, filter); } @Override protected void onDestroy() { // TODO Auto-generated method stub unregisterReceiver(receiver); super.onDestroy(); } } The main Activity has an intent filter for action.MAIN, category.LAUNCHER, category.DEFAULT, and category.CAR_DOCK. Any ideas on why this is happening?

    Read the article

  • Car physics in Chipmunk

    - by Richard Caetano
    Has anyone had experience with implementing car physics in chipmunk? Here's an example in Box2d: http://www.emanueleferonato.com/2009/04/06/two-ways-to-make-box2d-cars/ I'd like to port that over to chipmunk.

    Read the article

  • geting the median of 3 values using sheme car & cdr

    - by kristian Roger
    Hi still stuck with the ugly scheme the problem this time is to get the median of three values (easy) I did all these : (define (med x y z) (car(cdr(x y z))) and it was accepted but when testing it (med 3 4 5) I will get this error Error: attempt to call a non-procedure (2 3 4) and when entering letters inetead of number i got (md x y z) Error: undefined varia y (package user) using somthin else than x y z i got (md d l m) Error: undefined variable d (package user) so what is wronge ?!

    Read the article

  • Getting the median of 3 values using scheme's car & cdr

    - by kristian Roger
    The problem this time is to get the median of three values (easy) I did this: (define (med x y z) (car(cdr(x y z))) and it was accepted but when testing it: (med 3 4 5) I get this error: Error: attempt to call a non-procedure (2 3 4) And when entering letters instead of number i get: (md x y z) Error: undefined varia y (package user) Using something besides x y z I get: (md d l m) Error: undefined variable d (package user) the question was deleted dont know how anyway write a function that return the median of 3 values

    Read the article

  • C# How can I return my base class in a webservice

    - by HenriM
    I have a class Car and a derived SportsCar: Car Something like this: public class Car { public int TopSpeed{ get; set; } } public class SportsCar : Car { public string GirlFriend { get; set; } } I have a webservice with methods returning Cars i.e: [WebMethod] public Car GetCar() { return new Car() { TopSpeed = 100 }; } It returns: <Car> <TopSpeed>100</TopSpeed> </Car> I have another method that also returns cars like this: [WebMethod] public Car GetMyCar() { Car mycar = new SportsCar() { GirlFriend = "JLo", TopSpeed = 300 }; return mycar; } It compiles fine and everything, but when invoking it I get: System.InvalidOperationException: There was an error generating the XML document. --- System.InvalidOperationException: The type wsBaseDerived.SportsCar was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. I find it strange that it can't serialize this as a straight car, as mycar is a car. Adding XmlInclude on the WebMethod of ourse removes the error: [WebMethod] [XmlInclude(typeof(SportsCar))] public Car GetMyCar() { Car mycar = new SportsCar() { GirlFriend = "JLo", TopSpeed = 300 }; return mycar; } and it now returns: <Car xsi:type="SportsCar"> <TopSpeed>300</TopSpeed> <GirlFriend>JLo</GirlFriend> </Car> But I really want the base class returned, without the extra properties etc from the derived class. Is that at all possible without creating mappers etc? Please say yes ;)

    Read the article

  • Java Inheritance - Getting a Parameter from Parent Class

    - by Aaron
    I'm trying to take one parameter from the parent class of Car and add it to my array (carsParked), how can i do this? Parent Class public class Car { protected String regNo; //Car registration number protected String owner; //Name of the owner protected String carColor; /** Creates a Car object * @param rNo - registration number * @param own - name of the owner **/ public Car (String rNo, String own, String carColour) { regNo = rNo; owner = own; carColor = carColour; } /** @return The car registration number **/ public String getRegNo() { return regNo; } /** @return A String representation of the car details **/ public String getAsString() { return "Car: " + regNo + "\nColor: " + carColor; } public String getColor() { return carColor; } } Child Class public class Carpark extends Car { private String location; // Location of the Car Park private int capacity; // Capacity of the Car Park - how many cars it can hold private int carsIn; // Number of cars currently in the Car Park private String[] carsParked; /** Constructor for Carparks * @param loc - the Location of the Carpark * @param cap - the Capacity of the Carpark */ public Carpark (String locations, int room) { location = locations; capacity = room; } /** Records entry of a car into the car park */ public void driveIn() { carsIn = carsIn + 1; } /** Records the departure of a car from the car park */ public void driveOut() { carsIn = carsIn - 1; } /** Returns a String representation of information about the carpark */ public String getAsString() { return location + "\nCapacity: " + capacity + " Currently parked: " + carsIn + "\n*************************\n"; } }

    Read the article

  • Using Comparable to compare objects and sorting them in a TreeMap

    - by arjacsoh
    II cannot understand how should the natural ordering of class be "consistent with equals" when implementing the Comparable interface. I deteted a flaw in my program and therefore I deteced that in the documentantion of the interface Comparable. My problem is that although two Objects are considered as distinct on the base of equals method, the TreeMap structure treats them as equal and consequently does not accept the second insert. The sample code is: public class Car implements Comparable<Car> { int weight; String name; public Car(int w, String n) { weight=w; name=n; } public boolean equals(Object o){ if(o instanceof Car){ Car d = (Car)o; return ((d.name.equals(name)) && (d.weight==weight)); } return false; } public int hashCode(){ return weight/2 + 17; } public String toString(){ return "I am " +name+ " !!!"; } public int compareTo(Car d){ if(this.weight>d.weight) return 1; else if(this.weight<d.weight) return -1; else return 0; } /*public int compareTo(Car d){ return this.name.compareTo(d.name); }*/ } public static void main(String[] args) { Car d1 = new Car(100, "a"); Car d2 = new Car(110, "b"); Car d3 = new Car(110, "c"); Car d4 = new Car(100, "a"); Map<Car, Integer> m = new HashMap<Car, Integer>(); m.put(d1, 1); m.put(d2, 2); m.put(d3, 3); m.put(d4, 16); for(Map.Entry<Car, Integer> me : m.entrySet()) System.out.println(me.getKey().toString() + " " +me.getValue()); TreeMap<Car, Integer> tm = new TreeMap<Car, Integer>(m); System.out.println("After Sorting: "); for(Map.Entry<Car, Integer> me : tm.entrySet()) System.out.println(me.getKey().toString() + " " +me.getValue()); } The output is : I am a !!! 16 I am c !!! 3 I am b !!! 2 After Sorting: I am a !!! 16 I am c !!! 2 That is, that the object c has replaced (somewhat) object b. If I comment the original equals method and uncomment the second equals method, which compares the objects according name, the output is the expected: I am a !!! 16 I am c !!! 3 I am b !!! 2 After Sorting: I am a !!! 16 I am b !!! 2 I am c !!! 3 Why does it come around in this way and what should I alter in order to insert and sort different objects with some attributes of equal value in a TreeMap?

    Read the article

  • Casting To The Correct Subclass

    - by kap
    Hi Guys I hava a supeclass called Car with 3 subclasses. class Ford extends Car{ } class Chevrolet extends Car{ } class Audi extends Car{ } Now i have a function called printMessge(Car car) which will print a message of a particular car type. In the implementation i use if statements to test the instance of the classes like this. public int printMessge(Car car){ if((Ford)car instanceof Ford){ // print ford }else if((Chevrolet)car instanceof Chevrolet){ // print chevrolet }else if((Audi)car instanceof Audi){ // print Audi } } for instance if i call it for the first time with Ford printMessge(new Ford()), it prints the ford message but when i call it with printMessge(new Chevrolet()), i get EXCEPTION from the first if statement that Chevrolet cannot be cast to Ford. What am i doing wrong and what is the best way. thanks

    Read the article

  • What's the best way to move "a child up" in a C# XmlDocument?

    - by Mike
    Hi everyone, Given an xml structure like this: <garage> <car>Firebird</car> <car>Altima</car> <car>Prius</car> </garage> I want to "move" the Prius node "one level up" so it appears above the Altima node. Here's the final structure I want: <garage> <car>Firebird</car> <car>Prius</car> <car>Altima</car> </garage> So given the C# code: XmlNode priusNode = GetReferenceToPriusNode() What's the best way to cause the priusNode to "move up" one place in the garage's child list? Thanks! -Mike

    Read the article

  • how to solve nested list programs [closed]

    - by riya
    write a function to get most popular car that accepts a car detail as input and returns the most popular car name along with its average rating .Each element of car details list is a sublist that provides the below information about a car (a)name of a car(b)car price (c) list of ratings obtained by car from various agencies.Incase two cars have the same average rating then the car with the lesser price qualifies as most popular car? here's my solution-: (define-struct cardetails ("name" price list of '(ratings)) (define car1 (make-cardetails "toyota" 123 '( 1 2 3))) (define car2 (make-cardetails "santro" 321 '( 2 2 3))) (define car3 (make-cardetails "toyota" 100 '( 1 2 3))) (define cardetailslist(list(car1) (car2)(car 3))) (let loop ((count 0)) (let (len (length cardetailslist)) (if(< count len) (string-ref (string-ref n)0) now please tell me how to find maximum average and display car name.it's not a homework question tomorrow is my test and we have not been taught this concept in class although it is very important from test point of view

    Read the article

  • c++ inheritance

    - by Meloun
    Hi, i am trouble with this.. Is there some solution or i have to keep exactly class types? //header file Class Car { public: Car(); virtual ~Car(); }; class Bmw:Car { public: Bmw(); virtual ~Bmw(); }; void Start(Car& mycar) {}; //cpp file Car::Car(){} Car::~Car() {} Bmw::Bmw() :Car::Car(){} Bmw::~Bmw() {} int main() { Car myCar; Bmw myBmw; Start(myCar); //works Start(myBmw); //!! doesnt work return 0; }

    Read the article

  • What's the best way to move "a child up" in a .NET XmlDocument?

    - by Mike
    Given an XML structure like this: <garage> <car>Firebird</car> <car>Altima</car> <car>Prius</car> </garage> I want to "move" the Prius node "one level up" so it appears above the Altima node. Here's the final structure I want: <garage> <car>Firebird</car> <car>Prius</car> <car>Altima</car> </garage> So given the C# code: XmlNode priusNode = GetReferenceToPriusNode() What's the best way to cause the priusNode to "move up" one place in the garage's child list?

    Read the article

  • C++ class is not recognizing string data type

    - by reallythecrash
    I'm working on a program from my C++ textbook, and this this the first time I've really run into trouble. I just can't seem to see what is wrong here. Visual Studio is telling me Error: identifier "string" is undefined. I separated the program into three files. A header file for the class specification, a .cpp file for the class implementation and the main program file. These are the instructions from my book: Write a class named Car that has the following member variables: year. An int that holds the car's model year. make. A string that holds the make of the car. speed. An int that holds the car's current speed. In addition, the class should have the following member functions. Constructor. The constructor should accept the car's year and make as arguments and assign these values to the object's year and make member variables. The constructor should initialize the speed member variable to 0. Accessors. Appropriate accessor functions should be created to allow values to be retrieved from an object's year, make and speed member variables. There are more instructions, but they are not necessary to get this part to work. Here is my source code: // File Car.h -- Car class specification file #ifndef CAR_H #define CAR_H class Car { private: int year; string make; int speed; public: Car(int, string); int getYear(); string getMake(); int getSpeed(); }; #endif // File Car.cpp -- Car class function implementation file #include "Car.h" // Default Constructor Car::Car(int inputYear, string inputMake) { year = inputYear; make = inputMake; speed = 0; } // Accessors int Car::getYear() { return year; } string Car::getMake() { return make; } int Car::getSpeed() { return speed; } // Main program #include <iostream> #include <string> #include "Car.h" using namespace std; int main() { } I haven't written anything in the main program yet, because I can't get the class to compile. I've only linked the header file to the main program. Thanks in advance to all who take the time to investigate this problem for me.

    Read the article

  • Can I use a cheap inverter for my laptop?

    - by Georg
    I'm going to travel in a car this summer. It would be very nice if I could charge my laptop using the cigarette lighter. Because my computer is from Apple, there's no way to directly connect the two, therefore I need an inverter that provides 120V alternating current. There are many different models, ranging from very cheap to really expensive. The wave forms are: (from most expensive to cheapest) sine modified sine trapezoid square Can I use just any inverter or does it have to be a sine inverter? If so, what happens to my computer in case I use the wrong one. The laptop is a MacBook witch needs 60W.

    Read the article

  • Collision Detection fails with AI cars

    - by amit.r007
    I am making a car parking game in flash and AS3 wherein I drive my car along with other AI traffic cars moving along a specified path using Guidelines. I am using CDK for collision detection. The collision detection works fine with few AI cars, but doesn't seems to be working as required for few AI cars. When an AI car is moving on a path in a straight line it works fine.... but when the AI Car turns at 90 degress..... my car goes into the AI car (Overlapping) and it hits at the center of that AI car and then collision is Detected.... ..... I made a New path and used a new Sprite for AI car... but still the problem pursues....

    Read the article

  • What Do You Think About This Smelly Test?

    - by panamack
    I caught a whiff of a smell eminating from one of my tests, in a scenario akin to the following: [TestFixture] public void CarPresenterTests{ [Test] public void Throws_If_Cars_Wheels_Collection_Is_Null(){ IEnumerable<Wheels> wheels = null; var car = new Car(wheels); Assert.That( ()=>new CarPresenter(car), Throws.InstanceOf<ArgumentException>() .With.Message.EqualTo("Can't create if cars wheels is null)); } } public class CarPresenter{ public CarPresenter(Car car) { if(car.Wheels == null) throw new ArgumentException("Can't create if cars wheels is null); _car = car; _car.Wheels.Rolling += WheelsRollingHandler; } } I was struggling to describe what the problem is except that it seems wrong that a CarPresenter should attempt to dictate to a Car whether or not it's Wheels are initialised correctly. I wondered what pointers people here might give me?

    Read the article

  • Casting good practice

    - by phenevo
    Hi, I've got 3 classes namespace ServerPart public class Car { } namespace ServerPart public class SUV:Car { public string Name {get;set;} public string Color {get;set;) } And namespace WebSericePart public class Car { } namespace WebSericePart:Car public class SUV { public string Name {get;set;} public string Color {get;set;) } And I've translator namespace WebServicepart.Translators public static class ModelToContract { public Car[] ToCars(ServerPart.Car[] modelCars) { List<Car> contractCars=new List<Car>(); foreach(ServerPart.Car modelCar in modelCars) { contractCars.Add(ToCar(modelCar); } return contractCars.ToArray(); } public Car ToCar(ServerPart.Car modelCar) { if(modelCar is ServerPart.SUV) { return ToSUV(modelCar); } else { throw new NotImplementedException("Not supported type of Car")' } } public Car ToSUV(ServerPart.Car modelCar) { SUV suv=new SUV; // suv.Name=((ServerPart.SUV)modelCar).Name suv.Color=((ServerPart.SUV)modelCar).Color // ?? Is good practice ?? Or //ServerPart.SUV suv=(ServerPart.SUV)modelCar //suv.Name=suv.Name //suv.Color=suv.Color // is better ?? return suv; } } Do I used some else bad practices ?? Or Everything is OK :) ?

    Read the article

  • How can I extend a LINQ-to-SQL class without having to make changes every time the code is generated

    - by csharpnoob
    Hi, Update from comment: I need to extend linq-to-sql classes by own parameters and dont want to touch any generated classes. Any better suggestes are welcome. But I also don't want to do all attributes assignments all time again if the linq-to-sql classes are changing. so if vstudio generates new attribute to a class i have my own extended attributes kept separate, and the new innerited from the class itself Original question: i'm not sure if it's possible. I have a class car and a class mycar extended from class car. Class mycar has also a string list. Only difference. How can i cast now any car object to a mycar object without assigning all attributes each by hand. Like: Car car = new Car(); MyCar mcar = (MyCar) car; or MyCar mcar = new MyCar(car); or however i can extend car with own variables and don't have to do always Car car = new Car(); MyCar mcar = new MyCar(); mcar.name = car.name; mcar.xyz = car.xyz; ... Thanks.

    Read the article

  • Hibernate HQL m:n join problem

    - by smallufo
    I am very unfamiliar with SQL/HQL , and am currently stuck with this 'maybe' simple problem : I have two many-to-many Entities , with a relation table : Car , CarProblem , and Problem . One Car may have many Problems , One Problem may appear in many Cars, CarProblem is the association table with other properties . Now , I want to find Car(s) with specified Problem , how do I write such HQL ? All ids are Long type . I've tried a lot of join / inner-join combinations , but all in vain.. -- updated : Sorry , forget to mention : Car has many CarProblem Problem has many CarProblem Car and Problem are not directly connected in Java Object. -- update , java code below -- @Entity public class Car extends Model{ @OneToMany(mappedBy="car" , cascade=CascadeType.ALL) public Set<CarProblem> carProblems; } @Entity public class CarProblem extends Model{ @ManyToOne public Car car; @ManyToOne public Problem problem; ... other properties } @Entity public class Problem extends Model { other properties ... // not link to CarProblem , It seems not related to this problem // **This is a very stupid query , I want to get rid of it ...** public List<Car> findCars() { List<CarProblem> list = CarProblem.find("from CarProblem as cp where cp.problem.id = ? ", id).fetch(); Set<Car> result = new HashSet<Car>(); for(CarProblem cp : list) result.add(cp.car); return new ArrayList<Car>(result); } } The Model is from Play! framework , so these properties are all public .

    Read the article

  • OpenGL: Want to keep gun on top of car and be able to control angle. Having difficulties.

    - by Blair
    So I am making a simple game. I want to put a gun on top of a car so basically like a long rod in the middle of a black is how I am modelling it right now. I want to be able to control the angle of the gun. Basically it can go forward all the way so that it is parallel to the ground facing the direction the car is moving or it can point behind the car and any of the angles in between these positions. I have something like the following right now but its not really working. Is there an better way to do this that I am not seeing? #This will place the car glPushMatrix() glTranslatef(self.position.x,1.5,self.position.z) glRotated(self.rotation, 0.0, 1.0, 0.0) glScaled(0.5, 0.5, 0.5) glCallList(self.model.gl_list) glPopMatrix() #This will place the gun on top glPushMatrix() glTranslatef(self.position.x,2.5,self.position.z) glRotated(self.tube_angle, self.direction.z, 0.0, self.direction.x) print self.direction.z glRotated(45, self.position.z, 0.0, self.position.x) glScaled(1.0, 0.5, 1.0) glCallList(self.tube.gl_list) glPopMatrix() This almost works. It moves the gun up and down. But when the car moves around the angle of the gun changes. Not what I want.

    Read the article

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