Question

CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE....

CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE. SAME CODE SHOULD BE USED FOR THE DOCUMENTATION PURPOSES. ONLY INSERT THE JAVA DOC.

//Vehicle.java

public class Vehicle {

   private String manufacturer;

   private int seat;

   private String drivetrain;

   private float enginesize;

   private float weight;

//create getters for the attributes

   public String getmanufacturer() {

       return manufacturer;

   }

   public String getdrivetrain() {

       return drivetrain;

   }

   public int getseat() {

       return seat;

   }

   public float getenginesize() {

       return enginesize;

   }

   public float getweight() {

       return weight;

   }

//create setters for the attributs

   public void setmanufacturer(String manufacturer) {

       if (manufacturer.length() >= 2 && manufacturer.length() <= 20)

       {

           for (int i = 0; i < manufacturer.length(); i++)

           {

//check if string is in uppercase/lowercase/ has apostrophe/hypen/space/comma using ASCII Values

               if ((manufacturer.charAt(i) >= 65 && manufacturer.charAt(i) <= 90)
                       || (manufacturer.charAt(i) >= 97 && manufacturer.charAt(i) <= 122)
                       || manufacturer.charAt(i) == 32 || manufacturer.charAt(i) == 39 || manufacturer.charAt(i) == 44
                       || manufacturer.charAt(i) == 45)

               {

                   this.manufacturer = manufacturer;

               }

           }

       }

   }

//'=39

//32-space

//,=44

//-=45

//65-90=uppercase

//97-122=lowecase

   public void setseat(int seat) {

       if (seat >= 1 && seat <= 10)

       {

           this.seat = seat;

       }

   }

   public void setdrivetrain(String drivetrain) {

       if (drivetrain.equals("FWD") || drivetrain.equals("RWD") || drivetrain.equals("AWD")
               || drivetrain.equals("4WD"))

       {

           this.drivetrain = drivetrain;

       }

   }

   public void setenginesize(float enginesize) {

       if (enginesize >= 1.0 && enginesize <= 8.4)

       {

           this.enginesize = enginesize;

       }

   }

   public void setweight(float weight) {

       if (weight >= 3000 && weight <= 3500) // weight in pounds

       {

           this.weight = weight;

       }

   }

   public String toString() {
       return ("\n\nManufacturer: " + getmanufacturer()) +

               ("\nNumber of seats: " + getseat()) +

               ("\nDrivetrain: " + getdrivetrain()) +

               ("\nEnginesize: " + getenginesize()) +

               ("\nWeight: " + getweight());

   }

}

//Motorbike.java

public class Motorbike extends Vehicle {

   private String Style;
   private boolean Naked_body;

   public String getStyle() {
       return Style;
   }

   public void setStyle(String style) {
       if (style.equals("Touring") || style.equals("Trials") || style.equals("Sport") || style.equals("Scooter")
               || style.equals("Power Scooter") || style.equals("Motocross") || style.equals("Enduro")
               || style.equals("Dirt") || style.equals("Cruiser") || style.equals("Power Cruiser")
               || style.equals("Chopper")) {
           this.Style = style;
       }
   }

   public boolean isNaked_body() {
       return Naked_body;
   }

   public void setNaked_body(boolean naked_body) {
       Naked_body = naked_body;
   }

   public String toString() {
       super.toString();
       return ("\nStyle : " + getStyle()) + ("\nNaked Body : " + isNaked_body());
   }
}

Automobile.java


public class Automobile extends Vehicle {
   private String Model;
   private int year;

   public int getYear() {
       return year;
   }

   public void setYear(int year) {
       this.year = year;
   }

   public String getModel() {
       return Model;
   }

   public void setModel(String model) {
       if (model.length() >= 2 && model.length() <= 20)

       {

           for (int i = 0; i < model.length(); i++)

           {

//check if string is in uppercase/lowercase/ has apostrophe/hypen/space/comma using ASCII Values

               if ((model.charAt(i) >= 65 && model.charAt(i) <= 90)
                       || (model.charAt(i) >= 97 && model.charAt(i) <= 122) || model.charAt(i) == 32
                       || model.charAt(i) == 39 || model.charAt(i) == 44 || model.charAt(i) == 45)

               {

                   Model = model;

               }

           }

       }
   }

   public String toString() {
       super.toString();
       return ("\nModel : " + getModel()) + ("\nYear : " + getYear());
   }
}

Truck.java


public class Truck extends Vehicle {
   private double Max_Cargo_Load;
   private boolean Box_Style;

   public double getMax_Cargo_Load() {
       return Max_Cargo_Load;
   }

   public void setMax_Cargo_Load(double max_Cargo_Load) {
       if (max_Cargo_Load >= 3000 && max_Cargo_Load <= 3500) // weight in pounds

       {

           Max_Cargo_Load = max_Cargo_Load;

       }

   }

   public boolean isBox_Style() {
       return Box_Style;
   }

   public void setBox_Style(boolean box_Style) {
       Box_Style = box_Style;
   }

   public String toString() {
       super.toString();
       return ("\nMax Cargo Load : " + getMax_Cargo_Load()) + ("\nBox Style : " + isBox_Style());
   }
}

//Main.java

import java.util.*; //required for scanner class to work
class Main {

   public static void main(String[] args) {

       int seat;

       String manufacturer, drivetrain;

       float enginesize, weight;

       Vehicle vh = new Vehicle(); // create object for vehicle

       Scanner sc = new Scanner(System.in); // object for scanner (input)
      
       System.out.println("Enter the type of Vehicle (Motorbike,Automobile,Truck): ");
      
       String type;
      
       type = sc.next();
      
       if(type.equals("Motorbike"))
       {
           vh = new Motorbike();
           System.out.println("Enter Style: ");
           String temp = sc.next();
           ((Motorbike) vh).setStyle(temp);
           System.out.println("Naked Body: ");
           boolean naked = sc.nextBoolean();
           ((Motorbike) vh).setNaked_body(naked);
       }
      
       else if(type.equals("Automobile"))
       {
           vh = new Automobile();
           System.out.println("Enter Model: ");
           String Model = sc.next();
           ((Automobile) vh).setModel(Model);
           System.out.println("Enter Year: ");
           int year = sc.nextInt();
           ((Automobile) vh).setYear(year);
       }
      
       else if(type.equals("Truck"))
       {
           vh = new Truck();
           System.out.println("Enter Model: ");
           float max_Cargo_Load = sc.nextInt();
           ((Truck) vh).setMax_Cargo_Load(max_Cargo_Load);
           System.out.println("Box Style: ");
           boolean box_Style = sc.nextBoolean();
           ((Truck) vh).setBox_Style(box_Style);
       }

       System.out.println("Enter Manufacturer name: ");

       manufacturer = sc.nextLine();

       System.out.println("Enter Drivetrain: ");

       drivetrain = sc.nextLine();

       System.out.println("Enter number of seats: ");

       seat = sc.nextInt();

       System.out.println("Enter engine size in liters: ");

       enginesize = sc.nextFloat();

       System.out.println("Enter weight in pounds: ");

       weight = sc.nextFloat();

      
//put the input value in the set functions for all attributes

       vh.setmanufacturer(manufacturer);

       vh.setseat(seat);

       vh.setdrivetrain(drivetrain);

       vh.setenginesize(enginesize);

       vh.setweight(weight);

//use the getters to print the output

       System.out.println(vh.toString());
   }

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

package com.HomeworkLib.javadoc;
//Main.java
import java.util.*; // required for scanner class to work

class Main {
   /**
   * Entry point to run and test Vehicle Classes
   * @param args
   */
   public static void main(String[] args) {
       int seat;
       String manufacturer, drivetrain;
       float enginesize, weight;
       Vehicle vh = new Vehicle(); // create object for vehicle
       Scanner sc = new Scanner(System.in); // object for scanner (input)

       System.out.println("Enter the type of Vehicle (Motorbike,Automobile,Truck): ");

       String type;

       type = sc.next();

       if (type.equals("Motorbike")) {
           vh = new Motorbike();
           System.out.println("Enter Style: ");
           String temp = sc.next();
           ((Motorbike) vh).setStyle(temp);
           System.out.println("Naked Body: ");
           boolean naked = sc.nextBoolean();
           ((Motorbike) vh).setNaked_body(naked);
       }

       else if (type.equals("Automobile")) {
           vh = new Automobile();
           System.out.println("Enter Model: ");
           String Model = sc.next();
           ((Automobile) vh).setModel(Model);
           System.out.println("Enter Year: ");
           int year = sc.nextInt();
           ((Automobile) vh).setYear(year);
       }

       else if (type.equals("Truck")) {
           vh = new Truck();
           System.out.println("Enter Model: ");
           float max_Cargo_Load = sc.nextInt();
           ((Truck) vh).setMax_Cargo_Load(max_Cargo_Load);
           System.out.println("Box Style: ");
           boolean box_Style = sc.nextBoolean();
           ((Truck) vh).setBox_Style(box_Style);
       }
       System.out.println("Enter Manufacturer name: ");
       manufacturer = sc.nextLine();
       System.out.println("Enter Drivetrain: ");
       drivetrain = sc.nextLine();
       System.out.println("Enter number of seats: ");
       seat = sc.nextInt();
       System.out.println("Enter engine size in liters: ");
       enginesize = sc.nextFloat();
       System.out.println("Enter weight in pounds: ");
       weight = sc.nextFloat();

//put the input value in the set functions for all attributes
       vh.setmanufacturer(manufacturer);
       vh.setseat(seat);
       vh.setdrivetrain(drivetrain);
       vh.setenginesize(enginesize);
       vh.setweight(weight);
//use the getters to print the output
       System.out.println(vh.toString());
   }
}

-----------------

package com.HomeworkLib.javadoc;

public class Truck extends Vehicle {
   private double Max_Cargo_Load;
   private boolean Box_Style;

   /**
   * @return Max_Cargo_Load
   */
   public double getMax_Cargo_Load() {
       return Max_Cargo_Load;
   }

   /**
   * @param max_Cargo_Load
   */
   public void setMax_Cargo_Load(double max_Cargo_Load) {
       if (max_Cargo_Load >= 3000 && max_Cargo_Load <= 3500) // weight in pounds
       {
           Max_Cargo_Load = max_Cargo_Load;
       }
   }

   /**
   * @return Box_Style
   */
   public boolean isBox_Style() {
       return Box_Style;
   }

   /**
   * @param box_Style
   */
   public void setBox_Style(boolean box_Style) {
       Box_Style = box_Style;
   }

  
   /* (non-Javadoc)
   * @see com.HomeworkLib.javadoc.Vehicle#toString()
   */
   public String toString() {
       super.toString();
       return ("\nMax Cargo Load : " + getMax_Cargo_Load()) + ("\nBox Style : " + isBox_Style());
   }
}

------------

package com.HomeworkLib.javadoc;

public class Motorbike extends Vehicle {
   private String Style;
   private boolean Naked_body;

   /**
   * @return style : String
   */
   public String getStyle() {
       return Style;
   }

   /**
   * @param style
   */
   public void setStyle(String style) {
       if (style.equals("Touring") || style.equals("Trials") || style.equals("Sport") || style.equals("Scooter")
               || style.equals("Power Scooter") || style.equals("Motocross") || style.equals("Enduro")
               || style.equals("Dirt") || style.equals("Cruiser") || style.equals("Power Cruiser")
               || style.equals("Chopper")) {
           this.Style = style;
       }
   }

   /**
   * @return Naked_body : boolean
   */
   public boolean isNaked_body() {
       return Naked_body;
   }

   /**
   * @param naked_body
   */
   public void setNaked_body(boolean naked_body) {
       Naked_body = naked_body;
   }

   /*
   * (non-Javadoc)
   *
   * @see com.HomeworkLib.javadoc.Vehicle#toString()
   */
   public String toString() {
       super.toString();
       return ("\nStyle : " + getStyle()) + ("\nNaked Body : " + isNaked_body());
   }
}

-------------

package com.HomeworkLib.javadoc;

/**
* @author vinoth.sivakumar
*
*/
/**
* @author vinoth.sivakumar
*
*/
public class Vehicle {
   private String manufacturer;
   private int seat;
   private String drivetrain;
   private float enginesize;
   private float weight;

   //create getters for the attributes
   /**
   * @return
   */
   public String getmanufacturer() {
       return manufacturer;
   }

   /**
   * @return
   */
   public String getdrivetrain() {
       return drivetrain;
   }

   /**
   * @return
   */
   public int getseat() {
       return seat;
   }

   /**
   * @return enginesize
   */
   public float getenginesize() {
       return enginesize;
   }

   /**
   * @return weight
   */
   public float getweight() {
       return weight;
   }


   /**
   * Checks the Manufacturer name and sets the value to this.manufacturer
   * @param manufacturer
   * @return none
   */
   public void setmanufacturer(String manufacturer) {
       if (manufacturer.length() >= 2 && manufacturer.length() <= 20) {
           for (int i = 0; i < manufacturer.length(); i++) {
               //check if string is in uppercase/lowercase/ has apostrophe/hypen/space/comma using ASCII Values
               if ((manufacturer.charAt(i) >= 65 && manufacturer.charAt(i) <= 90)
                       || (manufacturer.charAt(i) >= 97 && manufacturer.charAt(i) <= 122)
                       || manufacturer.charAt(i) == 32 || manufacturer.charAt(i) == 39 || manufacturer.charAt(i) == 44
                       || manufacturer.charAt(i) == 45) {
                   this.manufacturer = manufacturer;
               }
           }
       }
   }


   /**
   * @param seat
   */
   public void setseat(int seat) {
       if (seat >= 1 && seat <= 10) {
           this.seat = seat;
       }
   }

   /**
   * @param drivetrain
   */
   public void setdrivetrain(String drivetrain) {
       if (drivetrain.equals("FWD") || drivetrain.equals("RWD") || drivetrain.equals("AWD")
               || drivetrain.equals("4WD")) {
           this.drivetrain = drivetrain;
       }
   }

   /**
   * @param enginesize
   */
   public void setenginesize(float enginesize) {
       if (enginesize >= 1.0 && enginesize <= 8.4) {
           this.enginesize = enginesize;
       }
   }

   /**
   * @param weight
   */
   public void setweight(float weight) {
       if (weight >= 3000 && weight <= 3500) // weight in pounds
       {
           this.weight = weight;
       }
   }

   /* (non-Javadoc)
   * @see java.lang.Object#toString()
   */
   public String toString() {
       return ("\n\nManufacturer: " + getmanufacturer()) + ("\nNumber of seats: " + getseat())
               + ("\nDrivetrain: " + getdrivetrain()) + ("\nEnginesize: " + getenginesize())
               + ("\nWeight: " + getweight());
   }
}


Output : NA.

Add a comment
Know the answer?
Add Answer to:
CONVERT THIS JAVA CODE WITH THE JAVA DOC GUIDELINES WHERE APPROPRIATE. DO NOT CHANGE THE CODE....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is not my entire line of code but the errors I'm getting are from this...

    This is not my entire line of code but the errors I'm getting are from this section. Can you please correct it and tell me where I went wrong? Thank you! package comJava; Vimport java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Scanner; //Lis public Driver { static List<RescueAnimal> list = new ArrayList<>(); public static void main(String[] args) { // Class variables // Create New Dog Dog d = new Dog(); // Create New Monkey Monkey m = new Monkey(); // Method...

  • Consider the Automobile class: public class Automobile {    private String model;    private int rating;...

    Consider the Automobile class: public class Automobile {    private String model;    private int rating; // a number 1, 2, 3, 4, 5    private boolean isTruck;    public Automobile(String model, boolean isTruck) {       this.model = model;       this.rating = 0; // unrated       this.isTruck = isTruck;    }        public Automobile(String model, int rating, boolean isTruck) {       this.model = model;       this.rating = rating;       this.isTruck = isTruck;    }                public String getModel()...

  • I need the following code to keep the current output but also include somthing similar to...

    I need the following code to keep the current output but also include somthing similar to this but with the correct details from the code. Truck Details: Skoda 100 Nathan Roy 150.5 3200 Details of Vehicle 1: Honda, 5 cd, owned by Peter England Details of Vehicle 2: Skoda, 100 cd, owned by Nathan Roy, 150.5 lbs load, 3200 tow --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- class Person {     private String name;        public Person()     {        name="None";     }       ...

  • JAVA- Complete the code by following guidelines in comments. class CircularList { private Link current; private...

    JAVA- Complete the code by following guidelines in comments. class CircularList { private Link current; private Link prev; public CircularList() { // implement: set both current and prev to null } public boolean isEmpty() { // implement return true; } public void insert(int id) { // implement: insert the new node behind the current node } public Link delete() { // implement: delete the node referred by current return null; } public Link delete(int id) { // implement: delete the...

  • Please make the following code modular. Therefore contained in a package with several classes and not...

    Please make the following code modular. Therefore contained in a package with several classes and not just one. import java.util.*; public class Q {    public static LinkedList<String> dogs = new LinkedList<String> ();    public static LinkedList<String> cats = new LinkedList<String> ();    public static LinkedList<String> animals = new LinkedList<String> ();    public static void enqueueCats(){        System.out.println("Enter name");        Scanner sc=new Scanner(System.in);        String name = sc.next();        cats.addLast(name);        animals.addLast(name);    }   ...

  • What am i doing wrong? can some take a look and tell me what should i...

    What am i doing wrong? can some take a look and tell me what should i change? in which line and how to fix it? Exercise 71130X WORK AREA RESULTS l import java.util.scanner; 3 class Numbersearch 5 public static void main (String args) 7 scanner scnew scanner (System.in); 9 System.out.println"Enter length of array 10 11 int size - sc.nextInt() 12 13 int arrnew intisize]; 14 15 for (int i -0; i < size; i+t) 17 System.out.println("Enter number for array index"+i:")i...

  • How to build Java test class? I am supposed to create both a recipe class, and...

    How to build Java test class? I am supposed to create both a recipe class, and then a class tester to test the recipe class. Below is what I have for the recipe class, but I have no idea what/or how I am supposed to go about creating the test class. Am I supposed to somehow call the recipe class within the test class? if so, how? Thanks in advance! This is my recipe class: package steppingstone5_recipe; /** * *...

  • Step 4: Add code that discards any extra entries at the propmt that asks if you...

    Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question:       "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...

  • java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and sh...

    java programming how would i modify the code below to add a GUI (with a main menu with graphics and buttons, etc...) and include an option to print a list of all students added in a grid format and short by name, course, instructor, and location. ///main public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<Student>students = new ArrayList<>(); int choice; while(true) { displayMenu(); choice = in.nextInt(); switch(choice) { case 1: in.nextLine(); System.out.println("Enter Student Name"); String name...

  • Can someone help me with my code.. I cant get an output. It says I do...

    Can someone help me with my code.. I cant get an output. It says I do not have a main method. HELP PLEASE. The instruction are in bold on the bottom of the code. package SteppingStones; //Denisse.Carbo import java.util.Scanner; import java.util.ArrayList; import java.util.List; public class SteppingStone5_Recipe { private String recipeName; private int servings; private List<String> recipeIngredients; private double totalRecipeCalories; public String getRecipeName() { return recipeName; } public void setRecipeName (string recipeName){ this.recipeName = recipeName; } public int getServings() { return...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT