Course Hero Logo

Backpacker.java - package hw1 /* * The basic operation is...

Course Hero uses AI to attempt to automatically extract content from documents to surface to you and others so you can study better, e.g., in search results, to enrich docs, and more. This preview shows page 1 - 2 out of 4 pages.

package hw1;/*** The basic operation is to visit a city for a given number of nights. The name* of the city, and the number of nights spent there, are added to the journal,* represented as a String. Each city has a certain hostel cost for staying* there. If the Backpacker doesn't have enough money, she must sleep at the* train station for some of those nights. The Backpacker's funds can be* replenished by calling home. However, the Backpacker's parents are stuck at* home working full time and may not have much sympathy for the Backpacker* running out of money while gallivanting around Europe. The amount they send* is proportional to the number of postcards the Backpacker has sent to them* since the last time she asked for money. Of course, sending a postcard from a* city costs money too. If things are so bad that the Backpacker doesn't even* have enough money to send a postcard home from her current city, we say that* the Backpacker is SOL (Shit Out of Luck)** @author Seyedehbahareh Hashemimovahed**/public class Backpacker {/*** Proportionality constant when calling home for more money: the amount of* money received is this constant multiplied by the number of postcards the* Backpacker has sent home (since the last time she called home for money*/public static final int SYMPATHY_FACTOR = 30;private int funds; // instance variable fund to keep track of money thebackpacker hasprivate City city; // instance variable type of City to keep track of currentcity we are inprivate String journal; // instance journal is to keep track of cities wehave been in and number of

Upload your study docs or become a

Course Hero member to access this document

Upload your study docs or become a

Course Hero member to access this document

End of preview. Want to read all 4 pages?

Upload your study docs or become a

Course Hero member to access this document

Term
Fall
Professor
N/A
Tags
Subroutine, Void type, Backpacker

Newly uploaded documents

Show More

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture