*T'Nora Green
*Assignment 6, Exercise 4
*************************************/
public void swapHardDrive(Computer otherComputer)
{
String temp; //temporary storage location
temp = otherComputer.hardDrive;
otherComputer.hardDrive = this.hardDrive;
this.hardDrive = temp;
}//end swapHardDrive.
/************************************
*T'Nora Green
*Assignment 6, Exercise 12
*************************************/
The two classes gave the output of:
10
20
30
60
50
/************************************
*T'Nora Green
*Assignment 6, Exercise 5
*************************************/
public boolean copyTo(Car5 newCar)
{
{
String truth;
if (newCar.make == this.make && newCar.year == this.year && newCar.color == this.color)
{
return false;
}//end if statement
if (newCar.make == this.make && newCar.year == this.year && newCar.color == this.color)
{
return false;
}//end if statement
else{
newCar = this;
return true;
}//end else statement
}//end of boolean
No comments:
Post a Comment