Advertisement
TomaszSoroka

Seven Summit

Feb 17th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.19 KB | None | 0 0
  1. Peak.java
  2.  class Peak {
  3.      String mountName;
  4.      boolean bassList;
  5.      boolean messnerList;
  6.      double elevationMt;
  7.      String country;
  8.      String range;
  9.      String continent;
  10.      int firstAscent;
  11.  }
  12.  
  13. SevenSummits.java
  14. public class SevenSummits {
  15.     public static void main(String[] args) {
  16.  
  17.         //https://en.wikipedia.org/wiki/Seven_Summits#The_Bass_and_Messner_lists
  18.  
  19.         //Tworzenie zmiennej typu obiektowego (deklaracja i inicjalizacja)
  20.  
  21.         Peak mountKosciuszko = new Peak(); //mountKosciuszko jest referencja na obiekt typu Peak
  22.         Peak puncakJaya = new Peak();
  23.         Peak mountVinson = new Peak();
  24.         Peak mountElbrus = new Peak();
  25.         Peak kilimanjaro = new Peak();
  26.         Peak denali = new Peak();
  27.         Peak aconcagua = new Peak();
  28.         Peak mountEverest = new Peak();
  29.  
  30.         mountKosciuszko.mountName = "Mount Kosciuszko";
  31.         mountKosciuszko.bassList = true;
  32.         mountKosciuszko.messnerList = false;
  33.         mountKosciuszko.elevationMt = 2.228;
  34.         mountKosciuszko.range = "Great Dividing Range";
  35.         mountKosciuszko.continent = "Australia";
  36.         mountKosciuszko.country = "Australia";
  37.         mountKosciuszko.firstAscent = 1840;
  38.  
  39.         puncakJaya.mountName = "Puncak Jaya" ;
  40.         puncakJaya.bassList = false;
  41.         puncakJaya.messnerList = true;
  42.         puncakJaya.elevationMt = 4.884;
  43.         puncakJaya.range = "Sudirman Range";
  44.         puncakJaya.continent = "Australasia";
  45.         puncakJaya.country = "Indonesia";
  46.         puncakJaya.firstAscent = 1962;
  47.  
  48.         mountVinson.mountName = "Mount Vinson" ;
  49.         mountVinson.bassList = true;
  50.         mountVinson.messnerList = true;
  51.         mountVinson.elevationMt = 4.892;
  52.         mountVinson.range = "Sentinel Range";
  53.         mountVinson.continent = "Antarctica";
  54.         mountVinson.country = "-";
  55.         mountVinson.firstAscent = 1966;
  56.  
  57.         mountElbrus.mountName = "Mount Elbrus" ;
  58.         mountElbrus.bassList = true;
  59.         mountElbrus.messnerList = true;
  60.         mountElbrus.elevationMt = 5.642;
  61.         mountElbrus.range = "Caucasus Mountains";
  62.         mountElbrus.continent = "Europe";
  63.         mountElbrus.country = "Russia";
  64.         mountElbrus.firstAscent = 1840;
  65.  
  66.         kilimanjaro.mountName = "Kilimanjaro" ;
  67.         kilimanjaro.bassList = true;
  68.         kilimanjaro.messnerList = true;
  69.         kilimanjaro.elevationMt = 5.895;
  70.         kilimanjaro.range = "-";
  71.         kilimanjaro.continent = "Africa";
  72.         kilimanjaro.country = "Tanzania";
  73.         kilimanjaro.firstAscent = 1889;
  74.  
  75.         denali.mountName = "Denali" ;
  76.         denali.bassList = true;
  77.         denali.messnerList = true;
  78.         denali.elevationMt = 6.194;
  79.         denali.range = "Alaska Range";
  80.         denali.continent = "North America";
  81.         denali.country = "United States";
  82.         denali.firstAscent = 1913;
  83.  
  84.         aconcagua.mountName = "Aconcagua" ;
  85.         aconcagua.bassList = true;
  86.         aconcagua.messnerList = true;
  87.         aconcagua.elevationMt = 6.961;
  88.         aconcagua.range = "Andes";
  89.         aconcagua.continent = "South America";
  90.         aconcagua.country = "Argentina";
  91.         aconcagua.firstAscent = 1897;
  92.  
  93.         mountEverest.mountName = "Mount Everest" ;
  94.         mountEverest.bassList = true;
  95.         mountEverest.messnerList = true;
  96.         mountEverest.elevationMt = 8848;
  97.         mountEverest.range = "Himalaya";
  98.         mountEverest.continent = "Asia";
  99.         mountEverest.country = "China/Nepal";
  100.         mountEverest.firstAscent = 1953;
  101.  
  102.         String mountKosciuszkoInfo = "1. " + mountKosciuszko.mountName
  103.                 + ", Bass List: " + mountKosciuszko.bassList
  104.                 + ", Messner List: " + mountKosciuszko.messnerList
  105.                 + ", Elevation (Mt): " + mountKosciuszko.elevationMt
  106.                 + ", Range: " + mountKosciuszko.range
  107.                 + ", Continent: " + mountKosciuszko.continent
  108.                 + ", Country: " + mountKosciuszko.country
  109.                 + ", First Ascent: " + mountKosciuszko.firstAscent;
  110.  
  111.         String puncakJayaInfo = "2. " + puncakJaya.mountName
  112.                 + ", Bass List: " + puncakJaya.bassList
  113.                 + ", Messner List: " + puncakJaya.messnerList
  114.                 + ", Elevation (Mt): " + puncakJaya.elevationMt
  115.                 + ", Range: " + puncakJaya.range
  116.                 + ", Continent: " + puncakJaya.continent
  117.                 + ", Country: " + puncakJaya.country
  118.                 + ", First Ascent: " + puncakJaya.firstAscent;
  119.  
  120.         String mountVinsonInfo = "3. " + mountVinson.mountName
  121.                 + ", Bass List: " + mountVinson.bassList
  122.                 + ", Messner List: " + mountVinson.messnerList
  123.                 + ", Elevation (Mt): " + mountVinson.elevationMt
  124.                 + ", Range: " + mountVinson.range
  125.                 + ", Continent: " + mountVinson.continent
  126.                 + ", Country: " + mountVinson.country
  127.                 + ", First Ascent: " + mountVinson.firstAscent;
  128.  
  129.         String mountElbrusInfo ="4. " + mountElbrus.mountName
  130.                 + ", Bass List: " + mountElbrus.bassList
  131.                 + ", Messner List: " + mountElbrus.messnerList
  132.                 + ", Elevation (Mt): " + mountElbrus.elevationMt
  133.                 + ", Range: " + mountElbrus.range
  134.                 + ", Continent: " + mountElbrus.continent
  135.                 + ", Country: " + mountElbrus.country
  136.                 + ", First Ascent: " + mountElbrus.firstAscent;
  137.  
  138.         String kilimanjaroInfo = "5. " + kilimanjaro.mountName
  139.                 + ", Bass List: " + kilimanjaro.bassList
  140.                 + ", Messner List: " + kilimanjaro.messnerList
  141.                 + ", Elevation (Mt): " + kilimanjaro.elevationMt
  142.                 + ", Range: " + kilimanjaro.range
  143.                 + ", Continent: " + kilimanjaro.continent
  144.                 + ", Country: " + kilimanjaro.country
  145.                 + ", First Ascent: " + kilimanjaro.firstAscent;
  146.  
  147.         String denaliInfo = "6. " + denali.mountName
  148.                 + ", Bass List: " + denali.bassList
  149.                 + ", Messner List: " + denali.messnerList
  150.                 + ", Elevation (Mt): " + denali.elevationMt
  151.                 + ", Range: " + denali.range
  152.                 + ", Continent: " + denali.continent
  153.                 + ", Country: " + denali.country
  154.                 + ", First Ascent: " + denali.firstAscent;
  155.  
  156.         String aconcaguaInfo = "7. " + aconcagua.mountName
  157.                 + ", Bass List: " + aconcagua.bassList
  158.                 + ", Messner List: " + aconcagua.messnerList
  159.                 + ", Elevation (Mt): " + aconcagua.elevationMt
  160.                 + ", Range: " + aconcagua.range
  161.                 + ", Continent: " + aconcagua.continent
  162.                 + ", Country: " + aconcagua.country
  163.                 + ", First Ascent: " + aconcagua.firstAscent;
  164.  
  165.         String mountEverestInfo = "8. " + mountEverest.mountName
  166.                 + ", Bass List: " + mountEverest.bassList
  167.                 + ", Messner List: " + mountEverest.messnerList
  168.                 + ", Elevation (Mt): " + mountEverest.elevationMt
  169.                 + ", Range: " + mountEverest.range
  170.                 + ", Continent: " + mountEverest.continent
  171.                 + ", Country: " + mountEverest.country
  172.                 + ", First Ascent: " + mountEverest.firstAscent;
  173.  
  174.         System.out.println("Seven Summit List: ");
  175.         System.out.println(mountKosciuszkoInfo);
  176.         System.out.println(puncakJayaInfo);
  177.         System.out.println(mountVinsonInfo);
  178.         System.out.println(mountElbrusInfo);
  179.         System.out.println(kilimanjaroInfo);
  180.         System.out.println(denaliInfo);
  181.         System.out.println(aconcaguaInfo);
  182.         System.out.println(mountEverestInfo);
  183.  
  184.         System.out.println("Czy Mt Elbus jest wyższy od Mt Everest?: "
  185.                 + (mountElbrus.elevationMt>mountEverest.elevationMt));
  186.         System.out.println("Czy Mt Elbus jest niższy od Mt Everest?: "
  187.                 + (mountElbrus.elevationMt<mountEverest.elevationMt));
  188.  
  189.         System.out.println("Czy zmienna mountElbrus jest typu Peak?");
  190.         boolean isPeak = mountElbrus instanceof Peak;
  191.         System.out.println(isPeak);
  192.  
  193.         // never ending CODE :D but it WORKS
  194.     }
  195. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement