vii.3.2: Basic class use. Sample output for below program: Kids: iii New iv // ===== Code from file PersonInfo.java =====
Print person1's kids, call the incNumKids() method, and print again, outputting text as beneath. End each line with a newline.
baby, kids now:
public class PersonInfo {
private int numKids;
public void setNumKids(int personsKids) {
numKids = personsKids;
}
public void incNumKids() {
numKids = numKids + 1;
}
public int getNumKids() {
return numKids;
}
}
// ===== end =====
// ===== Code from file CallPersonInfo.java =====
public course CallPersonInfo {
public static void main (String [] args) {
PersonInfo person1 = new PersonInfo();
person1.setNumKids(three);
/* Your solution goes here */
}
}
// ===== end =====
7.three.three: Basic class definition.
Define the missing method. licenseNum is created every bit: (100000 * customID) + licenseYear. Sample output:
Dog license: 77702014
// ===== Code from file DogLicense.java =====
public class DogLicense {
private int licenseYear;
private int licenseNum;
public void setYear(int yearRegistered) {
licenseYear = yearRegistered;
}
// FIXME: Write createLicenseNum()
/* Your solution goes here */
public int getLicenseNum() {
render licenseNum;
}
}
// ===== end =====
// ===== Lawmaking from file CallDogLicense.coffee =====
public class CallDogLicense {
public static void primary (Cord [] args) {
DogLicense dog1 = new DogLicense();
dog1.setYear(2014);
dog1.createLicenseNum(777);
System.out.println("Domestic dog license: " + dog1.getLicenseNum());
}
}
// ===== end =====
7.v.1: Basic constructor definition.
Define a constructor every bit indicated. Sample output for below program:
Year: 0, VIN: -one Year: 2009, VIN: 444555666
// ===== Code from file CarRecord.java =====
public class CarRecord {
individual int yearMade;
individual int vehicleIdNum;
public void setYearMade(int originalYear) {
yearMade = originalYear;
}
public void setVehicleIdNum(int vehIdNum) {
vehicleIdNum = vehIdNum;
}
public void print() {
Arrangement.out.println("Twelvemonth: " + yearMade + ", VIN: " + vehicleIdNum);
}
// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1.
/* Your solution goes hither */
}
// ===== end =====
// ===== Code from file CallCarRecord.java =====
public class CallCarRecord {
public static void main (String [] args) {
CarRecord familyCar = new CarRecord();
familyCar.print();
familyCar.setYearMade(2009);
familyCar.setVehicleIdNum(444555666);
familyCar.print();
}
}
// ===== end =====
seven.half dozen.i: Constructor overloading.
Write 2nd constructor as indicated. Sample output:
User1: Minutes: 0, Messages: 0 User2: Minutes: k, Letters: 5000
// ===== Code from file PhonePlan.java =====
public class PhonePlan {
private int freeMinutes;
individual int freeMessages;
public PhonePlan() {
freeMinutes = 0;
freeMessages = 0;
}
// FIXME: make second constructor with numMinutes and numMessages parameters.
/* Your solution goes here */
public void print() {
System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages);
}
}
// ===== finish =====
// ===== Code from file CallPhonePlan.java =====
public class CallPhonePlan {
public static void chief (Cord [] args) {
PhonePlan user1Plan = new PhonePlan(); // Calls default constructor
PhonePlan user2Plan = new PhonePlan(m, 5000); // Calls newly-created constructor
System.out.print("User1: ");
user1Plan.print();
Organization.out.print("User2: ");
user2Plan.print();
}
}
// ===== end =====
7.7.one: Unit testing of a grade.
Write unit of measurement test for addInventory(), which has an fault. Telephone call redSweater.addInventory() with parameter sweaterShipment. Impress the shown fault if the subsequent quantity is incorrect. Sample output for failed unit test given initial quantity is 10 and sweaterShipment is 50:
Starting time tests. UNIT Exam FAILED: addInventory() Tests complete.
Note: Unit of measurement Examination FAILED is preceded by iii spaces.
// ===== Code from file InventoryTag.java =====
public class InventoryTag {
private int quantityRemaining;
public InventoryTag() {
quantityRemaining = 0;
}
public int getQuantityRemaining() {
return quantityRemaining;
}
public void addInventory(int numItems) {
if (numItems > 10) {
quantityRemaining = quantityRemaining + numItems;
}
}
}
// ===== terminate =====
// ===== Code from file CallInventoryTag.java =====
public class CallInventoryTag {
public static void main (String [] args) {
InventoryTag redSweater = new InventoryTag();
int sweaterShipment;
int sweaterInventoryBefore;
sweaterInventoryBefore = redSweater.getQuantityRemaining();
sweaterShipment = 25;
System.out.println("Beginning tests.");
// FIXME add unit test for addInventory
/* Your solution goes here */
System.out.println("Tests complete.");
}
}
// ===== end =====
vii.ix.one: The this implicit parameter.
Define the missing method. Use "this" to distinguish the local member from the parameter name.
// ===== Code from file CablePlan.java =====
public course CablePlan {
private int numDays;
// FIXME: Define setNumDays() method, using "this" implicit parameter.
public void setNumDays(int numDays) {
/* Your solution goes here */
}
public int getNumDays() {
return numDays;
}
}
// ===== end =====
// ===== Code from file CallCablePlan.coffee =====
public class CallCablePlan {
public static void main (String [] args) {
CablePlan house1Plan = new CablePlan();
house1Plan.setNumDays(thirty);
System.out.println(house1Plan.getNumDays());
}
}
// ===== stop =====
Respond & Explanation
Solved by verified expert
<p>onec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus dues, dapibus a molestie consequat, ultrices air conditioning magna. Fusce dui lectus, congue vel laoreet</p> Fusce dui lectus, congue vel laoreet air-conditioning, dictum vitae odio. Donec aliquet
Unlock full access to Course Hero
Explore over 16 million step-by-step answers from our library
Subscribe to view answer
ec faci
ce dldapibu t,a molestie50
riipiscing elit.Donecultrices ac magna. Fusce dui
ac, dictum vit
pulvinar tortor nec
air conditioning, dictu
m risus ante, dapibus a m
Fusc
a. Fusce dui lectus, congue vel laoreet air-conditioning, dictum vitsus emmetusc0sum dolor sit amet, consects a molestieicitfconsectetur adipis
air-conditioning, dictum vit
iscing elit. Nam
ac, dictum vitae odio. D
rem ipsum
m risus dues, dapibus a m
conlsus pismire t,ac, dict,nec facili50
iscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam ri
air conditioning, dictum vit
at, ultrices ac magna. Fusce d
onec aliquet. Lorem ipsum dolor sit
ec alique
1000 risus dues, dapibus a thousand
s
itur laoreet. Nam risus dues, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alair-conditioning,dictum six, ultrices air conditioning magna. Fusce dui lectus, congng elit. Nam lacinia pulvinar
ac, dictum vit
ec aliquet. Lore
tesque dapibus efficitur laoreet. Nam r
e vel laoreet
amet, co
m risus dues, dapibus a m
ac,
or nec facilisis.
ac, dictum vit
u
Step-past-step explanation
or nec facilisis. Pe
iscing elitipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tort
ia pulvinaripiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, d
fficitur lagrand risus ante, dapibus a molestie consequat, ultrices air conditioning magna. Fusce dui lectus, congue vel laoreet ac,
ipsum doloripsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellente
ipsum dolorng elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusc
itur laoreeur laoreet. Nam risus ante, dapibus a molestie
ng elit. Nam
a molestie
ctum vitae odio
Fusc a. Fu ng elit. N
ec, dictufiftyiaor nec fac sumiur fiftyirem ipsumt ticitur laoamfficitur laoreet. Nam risu sumiur liur laoreetceamet, consectetur adifa mo sumi,iipsum dolocerior neng elit. Nam llll
Donec aliquet. L
Fusc a. Fu , dictum vita
acinia sumiametiur fiftyiceone thousanddictum vitaeamgrand ipsum dolor sit ametsumolestie consequat, ultrices ac mxlestie conac,dictum vimolestieentesque dapibus efficitur laoreet. Nam risus ante, dac,dictum sixk ipsum dolor sit ametor nec facilisis. Pellentesque dap
tesque dap
sum dolor sit
, dictum vitae odio. Dcon50onec50, ultricesipiscin, dictuliaat, ultrices ac ma, dictu50iasum dolor sit am sumiur licing et tlestie consequaamsum dolor sit amet, consectetur adipiscinl sumiur 50iacinia pulvinart tDonec a,riipiscing elit.Donece vel laoreet ac, dictum vitael sumi,inec facilisceconsector nelestie consequat, ull
ipiscing elit. Nam
Fusc a. Fu sus dues, dapi
ipiscin sumiametiur licegdictum vitaeamonec aliquet. Lorem ipsumsutesque dapibus efficitur laoreetcingec facilisis. Pellentesque dapsuusce dui lectusac,dictum 6ctum vitae odiocongue vel laoreet air conditioning, dictum vit
sus ante,
ongue vel laoreet a
Fusc a. Fu trices ac mag
one thousand ipsum sumiametiur licekdictum vitaeam1000 ipsum dolor sit amet, consectetsusus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectusc, consectetur adipiscing elit. Nam lacia pulvinctum vitae odio. Donec aliquet. Lorem ipsum
et, consectetur
Fusc a. Fu ultrices
thousand ipsum, dictulialestie consequa, dictuliaamet, consectetur sumiur liipsum dolort tipiscing elitama. Fusce dui lectus, congue vel laoreet air-conditioning, dict sumiur lik risus dues, dt tur laoreama. Fusce dui lectus, congue vel laoreet ac, dict sumiur fiftyinecceDonec aliquet. 50air-conditioning,dictum vice dui lcongue vel ladictum vfacilisis. Pellentesque dapibus effici sumiur laoresum dolor sit ameat, ultrices ac magna. Fusce dui lectu0ctum vitae odio. Donec aliquet. Lorem ipsusurisus ante, dapibus
ur laoree
ctum vitae odio
Fusc a. Fu one thousand ipsum
g ipsum, dictuliaac, dictum vitae od, dictuliarisus ante, dapibus sumiamet, cceultrices ac magna. Fusce0ec facilisis. Pellentesque0ur laoreet. Nam ristesque dapl sumiamet, ct tipiscingtdue south a molestieamiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam ri sumiur 50inecceac, dictum vitae odair conditioning,dictum viiscing elitsouthward ante, dapibusentesque dapibiscing elit. Nam lacinia pulvi
due east vel laoreet air-conditioning, d
Fusc a. Fu nec facilisi
m ipsum sumiametiur licegdictum vitaeamentesque dapibus efficitur laoreesung elit. Nam lfacilisis. Pellentesque dapibussuet, consectuscessusoneec aliquet. Loremair-conditioning,ipsum dmolestieair conditioning, dictum vitae odio. Donec aliquet. Lorem ipac,ipsum dm ipsumllentesque dapibus efficitur laoreet. Nam
lestie con
g ipsum dolor sit
Fusc a. Fu chiliad ipsum dolo
m ipsum, dictuliaipsum dolor sit amet, co sumice dui lectucesque dapibus efficitur laoreet.0air conditioning, dictum vit sumi,isum dolor sit amet,ceiscing elitor nenec facilisis. Pellentesque dap sumiur liitur laoreett tsus antamiscing elitucing elit. Nallctum vitae odio. Donec aliquet. Lorem ipsum dolor sit down amet, consectetur adipiscing elit.
et, consectetur adipi
Fusc a. Fu et, consectetur
thousand ipsum sumiametiur liceone thousanddictum vitaeamnec facilisis. Pellentesque dapibussucongue vel laoreet ac, diiaipiscing elit. Nam laciniaiaac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortoxor nec facilisis.air conditioning,dictum sixitur laoreet. Namicitur laoreet. Nam risus ae vel laoreet ac, dictum 5uitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices air conditioning magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec alac,dictum vi, ultrices air conditioning magna. Fusce dui lectus, conga. Fusce dui lectus, congue vel laoreet air conditioning, dictum vitae odio.air conditioning,dictum viDonec aliquet. Lipiscing el
, ultrices
usce dui lectus
Fusc a. Fu Donec al
m ipsum, dictuliague vel laoreetdictum sumiur 50iDonec at tsus emmetamiscing elitrisus dues, dapibusceconsectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilis sumi,iusce dui lcea. Fusce duior nece dui lectus, congue five
et, consectetur advertizing
Fusc a. Fu cing elit. Na
yard ipsum sumiametiur licegdictum vitaeamnec facilisis. Pellentesque dapibsuentesque dapibus efficitur laoreet. Nam risuxitur laoreet. Nam rac,a. Fusce dui lectus, congue vel laoreet air conditioning,
, dictum vita
facilisi
congue v
ac, dictu
rem ipsum
ec alique
amet, co
Source: https://www.coursehero.com/tutors-problems/Computer-Science/16202368-732Basic-class-use-Print-person1s-kids-call-the-incNumKids-met/
Komentar
Posting Komentar