Question

In: Computer Science

Submit a document with methods for an automobile class, and pseudo code indicating functionality of each...

Submit a document with methods for an automobile class, and pseudo code indicating functionality of each method.

Example:

public String RemoveVehicle(String autoMake, String autoModel, String autoColor, int autoYear)

If

values entered match values stored in private variables

remove vehicle information

else

return message indicating mismatch

Solutions

Expert Solution

Class Automobile can have below methods with their pseudocodes :

SET methods to assign the values of the variables entered by the user to the variables:

public void setautoMake(String Make)

{

     Assign the value of variable Make into the variable autoMake

     (autoMake   = Make)

}

public void setautoModel(String Model)

{

     Assign the value of variable Model into the variable autoModel

     (autoModel = Model)

}

public void setautoColor(String Color)

{

     Assign the value of variable Color into the variable autoColor

     (autoColor = Color)

}

public void setautoYear(int Year)

{

     Assign the value of variable Year into the variable autoYear

     (autoYear = Year)

}

Get methods to return the value of the variables set by the set methods above:

public String getautoMake ()

    {

       Return the value of the variable autoMake when the method getautoMake is

       Called in the main method.

        (return autoMake)

    }

public String getautoModel ()

    {

       Return the value of the variable autoModel when the method getautoModel is

       Called in the main method.

        (return autoModel)

    }

public String getautoColor ()

    {

       Return the value of the variable autoColor when the method getautoColor is

       Called in the main method.

        (return autoColor)

    }

public int getautoYear ()

    {

       Return the value of the variable autoYear when the method getautoYear is

       Called in the main method.

        (return autoYear)

    }

Speed method :

public void Speed (int speed)

     {

             Variable speed initialized to 0 in constructor of class Automobile

      Increment the value of the variable speed by 5

            (speed = speed + 5)

            Display the current value of speed

      }

Brakes method :

public void Brakes (int speed)

     {

             Variable speed initialized to 0 in constructor of class Automobile

      Decrement the value of the variable speed by 5

            (speed = speed - 5)

            Display the current value of speed

      }


Related Solutions

GIVEN THE CODE BELOW Given the following class: /** * Document class. */ public class Document...
GIVEN THE CODE BELOW Given the following class: /** * Document class. */ public class Document { private int words; /** * constructor * pre: none * post: A Document object created. Words initialized to 0. */ public Document() { words = 0; //default words } /** * Changes the number of document words. * pre: none * post: Words has been changed. */ public void setWords(int numWords) { words = numWords; } /** * Calculates the number of pages....
Convert this pseudo code program into sentences. import java.util.ArrayList; import java.util.Collections; class Bulgarian {    public...
Convert this pseudo code program into sentences. import java.util.ArrayList; import java.util.Collections; class Bulgarian {    public static void main(String[] args)    {        max_cards=45;        arr->new ArraryList        col=1;        card=0;        left=max_cards;        do{            col->random number            row->new ArrayList;            for i=0 to i<col            {                card++                add card into row            }   ...
Using Java, define a train class and write code to demonstrate its functionality The train should...
Using Java, define a train class and write code to demonstrate its functionality The train should run between Boston and New York, stopping at different, different station along the way. Provide output to indicate the train’s current status.
Write pseudo code for the following parts of class BinarySearchTree: a) find(x) b) contains(x) c) add(x)...
Write pseudo code for the following parts of class BinarySearchTree: a) find(x) b) contains(x) c) add(x) d) remove(x) e) splice(x) f) min() g) max() h) pred() i) succ() j) floor() k) ceil()
Please submit a Netbeans project with a class called RecursionExercises.java implementing the following methods: public static...
Please submit a Netbeans project with a class called RecursionExercises.java implementing the following methods: public static int reverse(int number) This method returns the positive integer obtained when the digits of the parameter is reversed. For example, when called with the parameter 12345, this method would return 54321. (Do this with proper integer arithmetic instead of just simply converting to String, reversing that and then using parseInt to extract the result). Hint: The number of digits of a number can be...
Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To...
Learning Objectives: To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method. Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure to...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line in the file lists a user ID, the ID of the movie the user watched, the rating the user gave for the movie, and the timestamp. For example line 1 indicates that the user’s ID is 196, the movie ID is 242, the user gave this movie a rating of 3, and the timestamp is 881250949. Given the file, find out the top similar...
submit the following files: Main.java Consider the following code: import java.util.Scanner; public class Main { public...
submit the following files: Main.java Consider the following code: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String input = ""; System.out.println("Enter the first number: "); input = in.nextLine(); int a = 0; int b = 0; a = Integer.parseInt(input); System.out.println("Enter the second number: "); input = in.nextLine(); b = Integer.parseInt(input); int result = 0; result = a/b; System.out.println("a/b : " + result); } Copy the code to your Main.java file...
Add code (see below for details) to the methods "set" and "get" in the following class,...
Add code (see below for details) to the methods "set" and "get" in the following class, ArrayTen.java, so that these two methods catch the exception java.lang.ArrayIndexOutOfBoundsException if an illegal index is used, and in turn throw java.lang.IndexOutOfBoundsException instead. Modify the "main" method to catch java.lang.IndexOutOfBoundsException and, when such an exception is caught, print the exception as well as the stack trace. public class ArrayTen { private String myData[] = new String[10]; public void set(int index, String value) { myData[index] =...
java code Add the following methods to the LinkedQueue class, and create a test driver for...
java code Add the following methods to the LinkedQueue class, and create a test driver for each to show that they work correctly. In order to practice your linked list cod- ing skills, code each of these methods by accessing the internal variables of the LinkedQueue, not by calling the previously de?ined public methods of the class. String toString() creates and returns a string that correctly represents the current queue. Such a method could prove useful for testing and debugging...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT