Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
assignment 3
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.util.Scanner; import java.lang.Math; import java.util.ArrayList; class Rextester { public static void main(String args[]) { System.out.println("Hello, World!"); } } class Boxcar { private int numUnits = 0; private String cargo = ""; private boolean repair = false; private String tempstr = ""; public Boxcar() { this("gizmos", 5, false); } public Boxcar(String c, int u, boolean r) { tempstr = c.toLowerCase(); if ( (tempstr).equals("gizmos") || (tempstr).equals("gadgets") || (tempstr).equals("widgets") || (tempstr).equals("wadgets") ) cargo = tempstr; else { cargo = "gizmos"; } if ( (u >= 0) && (u <= 10) ) numUnits = u; else { numUnits = 0; } if ( r == true ) { repair = r; numUnits = 0; } else { repair = r; } } public void loadCargo() { if (repair == false) { if (numUnits < 10) numUnits++; } else numUnits = 0; } public String getCargo() { return (cargo); } public void setCargo(String c) { tempstr = c.toLowerCase(); if ( (tempstr).equals("gizmos") || (tempstr).equals("gadgets") || (tempstr).equals("widgets") || (tempstr).equals("wadgets") ) cargo = tempstr; else { cargo = "gizmos"; } } public boolean isFull() { if (numUnits == 10) { return true; } else { return false; } } public String lazy() { if (repair == true) return ("in repair"); else return ("in service"); } public void callForRepair() { repair = true; numUnits = 0; } public String toString() { return (numUnits + " " + cargo + "\t" + lazy()); } }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
String is not reference Type??
Sqrt
updated
Triangle
AllStar
Complex number multiplication (leetcode)
Basic Matrix
4d
Happy Numbers in Java
Preference List
Please log in to post a comment.